/** * Changes the maximum number of bytes the cache can store and queues a job * to trim the existing store, if necessary. */ public synchronized void setMaxSize(long maxSize) { this.maxSize = maxSize; executorService.submit(cleanupCallable); }
@Override public void run() { ConsumeMessageConcurrentlyService.this.consumeExecutor.submit(consumeRequest); } }, 5000, TimeUnit.MILLISECONDS);
/** * Changes the maximum number of bytes the cache can store and queues a job * to trim the existing store, if necessary. */ public synchronized void setMaxSize(long maxSize) { this.maxSize = maxSize; executorService.submit(cleanupCallable); }
/** * Submits a copy task, returns immediately without waiting for completion. * * @param task the copy task */ public <T> void submit(Callable<T> task) { mPool.submit(task); }
public void submit(Runnable runnable) { processor.submit(runnable); }
public Future<?> submit(Runnable runnable) { return threadPool.submit(runnable); }
protected Future<Void> submitTask(Callable<Void> task) { return threadPool.submit(task); }
private synchronized void invokeAll(long flushInterval) { ArrayList<Flusher> tasks = pendingFlushMap.get(flushInterval); if (tasks != null) { for (Flusher f : tasks) { threadPool.submit(f); } } }
public void waitForCompletion() throws ExecutionException, InterruptedException { // because the pool is single threaded, // all previously submitted tasks are completed when this task finishes asyncRestPool.submit(new Runnable() { public void run() { } }).get(); }
/* visible for testing */ boolean doWarmUp() { Future future = null; try { future = threadPoolExecutor.submit(updateTask); future.get(warmUpTimeoutMs, TimeUnit.MILLISECONDS); // block until done or timeout return true; } catch (Exception e) { logger.warn("Best effort warm up failed", e); } finally { if (future != null) { future.cancel(true); } } return false; }
private void sendBulkAsync(final HttpClient.OutputStreamHandler outputStreamHandler, final boolean logBulkErrors) { try { asyncESPool.submit(new Runnable() { @Override public void run() { sendBulk(outputStreamHandler, logBulkErrors); } }); } catch (RejectedExecutionException e) { ExecutorUtils.logRejectionWarning(e); } }
@Override public void submitConsumeRequest( final List<MessageExt> msgs, final ProcessQueue processQueue, final MessageQueue messageQueue, final boolean dispathToConsume) { if (dispathToConsume) { ConsumeRequest consumeRequest = new ConsumeRequest(processQueue, messageQueue); this.consumeExecutor.submit(consumeRequest); } }
private synchronized void startIDBlockGetter() { Preconditions.checkArgument(idBlockFuture == null, idBlockFuture); if (closed) return; //Don't renew anymore if closed //Renew buffer log.debug("Starting id block renewal thread upon {}", currentIndex); idBlockGetter = new IDBlockGetter(idAuthority, partition, idNamespace, renewTimeout); idBlockFuture = exec.submit(idBlockGetter); }
@Override public IFutureResult submitRunnable(final Runnable runnable) { return new FutureResultAdapter(super.submit(runnable)); }
@Override public void process(AlluxioURI path, List<Inode> prefixInodes) { mPool.submit(new ProcessPathTask(path, prefixInodes)); }
private synchronized void startIDBlockGetter() { Preconditions.checkArgument(idBlockFuture == null, idBlockFuture); if (closed) return; //Don't renew anymore if closed //Renew buffer log.debug("Starting id block renewal thread upon {}", currentIndex); idBlockGetter = new IDBlockGetter(idAuthority, partition, idNamespace, renewTimeout); idBlockFuture = exec.submit(idBlockGetter); }
/** * Allocate instance to a process and return. This call blocks until item * can be assigned to a thread. * * @param item Input to a Processor * @throws RejectedExecutionException -- A RuntimeException when there is an * uncaught exception in the queue. Resolution is for the calling class to shutdown * the wrapper and create a new threadpool. * */ public synchronized void put(I item) throws RejectedExecutionException { Integer procId = getProcessor(); if (procId == null) { throw new RejectedExecutionException("Couldn't submit item to threadpool: " + item); } final int itemId = submittedItemCounter++; CallableJob<I,O> job = new CallableJob<>(item, itemId, processorList.get(procId), procId, callback); threadPool.submit(job); }
@SuppressWarnings("rawtypes") public Future<GoogleAnalyticsResponse> postAsync(final GoogleAnalyticsRequest request) { if (!config.isEnabled()) { return null; } Future<GoogleAnalyticsResponse> future = getExecutor().submit(new Callable<GoogleAnalyticsResponse>() { public GoogleAnalyticsResponse call() throws Exception { return post(request); } }); return future; }
@Test(expected = RejectedExecutionException.class) public void testRejectedExecution() throws Exception { for (int i = 0; i < 10; i++) { lowCapacityPool.submit(sleepABit); } } }
@Override public Subscription schedule(final Action0 action) { if (subscription.isUnsubscribed()) { // don't schedule, we are unsubscribed return Subscriptions.unsubscribed(); } // This is internal RxJava API but it is too useful. ScheduledAction sa = new ScheduledAction(action); subscription.add(sa); sa.addParent(subscription); ThreadPoolExecutor executor = (ThreadPoolExecutor) threadPool.getExecutor(); FutureTask<?> f = (FutureTask<?>) executor.submit(sa); sa.add(new FutureCompleterWithConfigurableInterrupt(f, shouldInterruptThread, executor)); return sa; }