Package org.onlab.util
Class SharedExecutors
- java.lang.Object
-
- org.onlab.util.SharedExecutors
-
public final class SharedExecutors extends Object
Utility for managing a set of shared execution resources, such as a timer, single thread executor and thread pool 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 ExecutorService
getPoolThreadExecutor()
Returns the shared thread pool executor.static ExecutorService
getSingleThreadExecutor()
Returns the shared single thread executor.static Timer
getTimer()
Returns the shared timer.static void
setMetricsService(MetricsService metricsService)
Enables or disables calculation of the pool performance metrics.static void
setPoolSize(int poolSize)
Sets the shared thread pool size.static void
shutdown()
Shuts down all shared timers and executors and therefore should be called only by the framework.
-
-
-
Field Detail
-
DEFAULT_POOL_SIZE
public static final int DEFAULT_POOL_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getSingleThreadExecutor
public static ExecutorService getSingleThreadExecutor()
Returns the shared single thread executor.- Returns:
- shared single thread executor
-
getPoolThreadExecutor
public static ExecutorService getPoolThreadExecutor()
Returns the shared thread pool executor.- Returns:
- shared executor pool
-
getTimer
public static Timer getTimer()
Returns the shared timer.- Returns:
- shared timer
-
setPoolSize
public static void setPoolSize(int poolSize)
Sets the shared thread pool size.- Parameters:
poolSize
- new pool size
-
setMetricsService
public static void setMetricsService(MetricsService metricsService)
Enables or disables calculation of the pool performance metrics. If the metrics service is not null metric collection will be enabled; otherwise it will be disabled.- Parameters:
metricsService
- optional metric service
-
shutdown
public static void shutdown()
Shuts down all shared timers and executors and therefore should be called only by the framework.
-
-