Package org.onlab.util
Class SharedScheduledExecutors
- java.lang.Object
-
- org.onlab.util.SharedScheduledExecutors
-
public final class SharedScheduledExecutors extends java.lang.Object
Utility for managing a set of shared execution resources, such as a single thread scheduled executor and thread pool scheduled executor for use by various parts of the platform or by applications.Whenever possible, use of these shared resources is encouraged over creating separate ones.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_POOL_SIZE
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static SharedScheduledExecutorService
getPoolThreadExecutor()
Returns the shared scheduled thread pool executor.static SharedScheduledExecutorService
getSingleThreadExecutor()
Returns the shared scheduled single thread executor.static java.util.concurrent.ScheduledFuture<?>
newTimeout(java.lang.Runnable task, long delay, java.util.concurrent.TimeUnit unit)
Executes one-shot timer task on shared thread pool.static void
setPoolSize(int poolSize)
Configures the shared scheduled thread pool size.static void
shutdown()
Shuts down all shared scheduled executors.
-
-
-
Field Detail
-
DEFAULT_POOL_SIZE
public static final int DEFAULT_POOL_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getSingleThreadExecutor
public static SharedScheduledExecutorService getSingleThreadExecutor()
Returns the shared scheduled single thread executor.- Returns:
- shared scheduled single thread executor
-
newTimeout
public static java.util.concurrent.ScheduledFuture<?> newTimeout(java.lang.Runnable task, long delay, java.util.concurrent.TimeUnit unit)
Executes one-shot timer task on shared thread pool.- Parameters:
task
- timer task to executedelay
- before executing the taskunit
- of delay- Returns:
- a ScheduledFuture representing pending completion of the task and whose get() method will return null upon completion
-
getPoolThreadExecutor
public static SharedScheduledExecutorService getPoolThreadExecutor()
Returns the shared scheduled thread pool executor.- Returns:
- shared scheduled executor pool
-
setPoolSize
public static void setPoolSize(int poolSize)
Configures the shared scheduled thread pool size.- Parameters:
poolSize
- new pool size
-
shutdown
public static void shutdown()
Shuts down all shared scheduled executors. This is not intended to be called by application directly.
-
-