Package net.datenwerke.async
Interface DwAsyncService
- All Known Implementing Classes:
DwAsyncServiceImpl
public interface DwAsyncService
A service that allows to run asynchronous tasks.
Via the service managed threadpools (see
ExecutorService) can be
created.-
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTerminationForPool(String poolToken, long timeout, TimeUnit unit) Blocks until all tasks have completed execution after a shutdown request for the given poolintReturns the approximately number of active threads in all pools.longReturns the approximate total number of tasks that have completed execution summed over all pools.intReturns the number of poolsReturns the pool identified by poolToken or null.longReturns the approximate total number of tasks that have ever been scheduled for execution summed over all pools.initPool(String poolToken, PoolConfiguration configuration) Initializes a new pool for the given configuration.booleanisShutdownPool(String poolToken) Returns true if the pool was asked to shutdown.booleanisTerminatedPool(String poolToken) Returns true if all tasks have completed following shut down.booleanpoolExists(String poolToken) Returns true if pool identified by poolToken existsvoidCalls shutdown on all pools.Calls shutdownNow on all pools.Terminates the default thread pool.voidshutdownPool(String poolToken) If pool exists, the pool is asked to orderly shutdown.shutdownPoolNow(String poolToken) If pool exists, the pool is shutdown immediately.voidSubmits a task to be run on the default thread poolvoidShuts down the default thread pool
-
Method Details
-
poolExists
Returns true if pool identified by poolToken exists- Parameters:
poolToken- The pool identifier
-
initPool
Initializes a new pool for the given configuration. If a pool for poolToken already exists, the old pool is terminated.- Parameters:
poolToken-configuration-- Returns:
- The pool
-
getPool
Returns the pool identified by poolToken or null.- Parameters:
poolToken-
-
shutdownPool
If pool exists, the pool is asked to orderly shutdown.- Parameters:
poolToken-- See Also:
-
shutdownPoolNow
If pool exists, the pool is shutdown immediately.- Parameters:
poolToken-- Returns:
- list of tasks that never commenced execution
- See Also:
-
awaitTerminationForPool
boolean awaitTerminationForPool(String poolToken, long timeout, TimeUnit unit) throws InterruptedException Blocks until all tasks have completed execution after a shutdown request for the given pool- Parameters:
poolToken- The pool identifiertimeout-unit-- Throws:
InterruptedException- See Also:
-
isShutdownPool
Returns true if the pool was asked to shutdown.- Parameters:
poolToken-- See Also:
-
isTerminatedPool
Returns true if all tasks have completed following shut down.- Parameters:
poolToken-
-
getNrOfPools
int getNrOfPools()Returns the number of pools- Returns:
- the number of pools
-
getActiveCountAll
int getActiveCountAll()Returns the approximately number of active threads in all pools.- Returns:
- the number of threads
-
getTaskCountAll
long getTaskCountAll()Returns the approximate total number of tasks that have ever been scheduled for execution summed over all pools.- Returns:
- The number of tasks
-
getCompletedTaskCountAll
long getCompletedTaskCountAll()Returns the approximate total number of tasks that have completed execution summed over all pools.- Returns:
- the number of tasks
-
shutdownAll
void shutdownAll()Calls shutdown on all pools.- See Also:
-
shutdownAllNow
Calls shutdownNow on all pools.- See Also:
-
submit
Submits a task to be run on the default thread pool- Parameters:
task-
-
suhtdownDefault
void suhtdownDefault()Shuts down the default thread pool -
shutdownNowDefault
Terminates the default thread pool.
-