Package org.apache.cassandra.concurrent
Interface ExecutorPlus
- All Superinterfaces:
Executor,ExecutorService,ResizableThreadPool
- All Known Subinterfaces:
LocalAwareExecutorPlus,LocalAwareSequentialExecutorPlus,ScheduledExecutorPlus,SequentialExecutorPlus
- All Known Implementing Classes:
CompactionManager.ValidationExecutor,ImmediateExecutor,LocalAwareSingleThreadExecutorPlus,LocalAwareThreadPoolExecutorPlus,ScheduledThreadPoolExecutorPlus,SEPExecutor,SingleThreadExecutorPlus,ThreadPoolExecutorPlus,WrappedExecutorPlus
Cassandra's extension of
ExecutorService, using our own Future, supporting
inExecutor(), and execution with associated resources execute(WithResources, Runnable)
(which is primarily used for encapsulating ExecutorLocals without leaking implementing classes).-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoidexecute(WithResources withResources, Runnable task) Invoketask.booleaninvokeAll(Collection<? extends Callable<T>> tasks) invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) default <T> TinvokeAny(Collection<? extends Callable<T>> tasks) default <T> TinvokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) default voidMAY executetaskimmediately, if the calling thread is permitted to do so.Future<?>OverridesExecutorService.submit(Runnable)to return a CassandraFuture<T> Future<T>OverridesExecutorService.submit(Runnable, Object)to return a CassandraFuture<T> Future<T>OverridesExecutorService.submit(Callable)to return a CassandraFutureFuture<?>submit(WithResources withResources, Runnable task) Invoketask, returning a future yieldingnullif successful, or the abnormal termination oftaskotherwise.<T> Future<T>submit(WithResources withResources, Runnable task, T result) Invoketask, returning a future yieldingresultif successful, or the abnormal termination oftaskotherwise.<T> Future<T>submit(WithResources withResources, Callable<T> task) Invoketask, returning a future representing this computation.Methods inherited from interface java.util.concurrent.ExecutorService
awaitTermination, isShutdown, isTerminated, shutdown, shutdownNowMethods inherited from interface org.apache.cassandra.concurrent.ResizableThreadPool
getActiveTaskCount, getCompletedTaskCount, getCorePoolSize, getMaximumPoolSize, getMaxTasksQueued, getPendingTaskCount, oldestTaskQueueTime, setCorePoolSize, setMaximumPoolSize
-
Method Details
-
maybeExecuteImmediately
MAY executetaskimmediately, if the calling thread is permitted to do so. -
submit
OverridesExecutorService.submit(Callable)to return a CassandraFuture- Specified by:
submitin interfaceExecutorService
-
submit
OverridesExecutorService.submit(Runnable, Object)to return a CassandraFuture- Specified by:
submitin interfaceExecutorService
-
submit
OverridesExecutorService.submit(Runnable)to return a CassandraFuture- Specified by:
submitin interfaceExecutorService
-
execute
Invoketask. The invoking thread will first instantiate the resources provided before invokingtask, so that thread state may be modified and cleaned up. The invoking thread will execute something semantically equivlent to:try (Closeable close = withResources.get()) { task.run(); }- Parameters:
withResources- the resources to create and hold while executingtasktask- the task to execute
-
submit
Invoketask, returning a future representing this computation. The invoking thread will first instantiate the resources provided before invokingtask, so that thread state may be modified and cleaned up. The invoking thread will execute something semantically equivlent to:try (Closeable close = withResources.get()) { return task.call(); }- Parameters:
withResources- the resources to create and hold while executingtasktask- the task to execute
-
submit
Invoketask, returning a future yieldingnullif successful, or the abnormal termination oftaskotherwise. The invoking thread will first instantiate the resources provided before invokingtask, so that thread state may be modified and cleaned uptry (Closeable close = withResources.get()) { task.run(); return null; }- Parameters:
withResources- the resources to create and hold while executingtasktask- the task to execute
-
submit
Invoketask, returning a future yieldingresultif successful, or the abnormal termination oftaskotherwise. The invoking thread will first instantiate the resources provided before invokingtask, so that thread state may be modified and cleaned up. The invoking thread will execute something semantically equivlent to:try (Closeable close = withResources.get()) { task.run(); return result; }- Parameters:
withResources- the resources to create and hold while executingtasktask- the task to executeresult- the result if successful
-
inExecutor
boolean inExecutor()- Returns:
- true iff the caller is a worker thread actively serving this executor
-
invokeAll
default <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException - Specified by:
invokeAllin interfaceExecutorService- Throws:
InterruptedException
-
invokeAll
default <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException - Specified by:
invokeAllin interfaceExecutorService- Throws:
InterruptedException
-
invokeAny
default <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException - Specified by:
invokeAnyin interfaceExecutorService- Throws:
InterruptedExceptionExecutionException
-
invokeAny
default <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
invokeAnyin interfaceExecutorService- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-