Package org.onlab.util
Class SharedExecutors
- java.lang.Object
- 
- org.onlab.util.SharedExecutors
 
- 
 public final class SharedExecutors extends java.lang.ObjectUtility 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 SummaryFields Modifier and Type Field Description static intDEFAULT_POOL_SIZE
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.concurrent.ExecutorServicegetPoolThreadExecutor()Returns the shared thread pool executor.static java.util.concurrent.ExecutorServicegetSingleThreadExecutor()Returns the shared single thread executor.static java.util.TimergetTimer()Returns the shared timer.static voidsetMetricsService(MetricsService metricsService)Enables or disables calculation of the pool performance metrics.static voidsetPoolSize(int poolSize)Sets the shared thread pool size.static voidshutdown()Shuts down all shared timers and executors and therefore should be called only by the framework.
 
- 
- 
- 
Field Detail- 
DEFAULT_POOL_SIZEpublic static final int DEFAULT_POOL_SIZE - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
getSingleThreadExecutorpublic static java.util.concurrent.ExecutorService getSingleThreadExecutor() Returns the shared single thread executor.- Returns:
- shared single thread executor
 
 - 
getPoolThreadExecutorpublic static java.util.concurrent.ExecutorService getPoolThreadExecutor() Returns the shared thread pool executor.- Returns:
- shared executor pool
 
 - 
getTimerpublic static java.util.Timer getTimer() Returns the shared timer.- Returns:
- shared timer
 
 - 
setPoolSizepublic static void setPoolSize(int poolSize) Sets the shared thread pool size.- Parameters:
- poolSize- new pool size
 
 - 
setMetricsServicepublic 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
 
 - 
shutdownpublic static void shutdown() Shuts down all shared timers and executors and therefore should be called only by the framework.
 
- 
 
-