Thomas Vachuska
Committed by Gerrit Code Review

Cleaning up documentation and some white-space.

Change-Id: I3d8ba130f0d7b99c15e52a95a021a8a81e1a1a5f
...@@ -16,61 +16,66 @@ ...@@ -16,61 +16,66 @@
16 16
17 package org.onlab.util; 17 package org.onlab.util;
18 18
19 - 19 +import java.util.Timer;
20 import java.util.concurrent.ExecutorService; 20 import java.util.concurrent.ExecutorService;
21 -import java.util.concurrent.Executors;
22 21
22 +import static java.util.concurrent.Executors.newFixedThreadPool;
23 +import static java.util.concurrent.Executors.newSingleThreadExecutor;
23 import static org.onlab.util.Tools.groupedThreads; 24 import static org.onlab.util.Tools.groupedThreads;
24 25
25 /** 26 /**
26 - * SharedExecutors is designed to use thread pool for applications. 27 + * Utility for managing a set of shared execution resources, such as a timer,
27 - * SharedExecutors is recommended for applications instead of creating new thread groups. 28 + * single thread executor and thread pool executor for use by various parts of
29 + * the platform or by applications.
30 + * <p>
31 + * Whenever possible, use of these shared resources is encouraged over creating
32 + * separate ones.
33 + * </p>
28 */ 34 */
29 public final class SharedExecutors { 35 public final class SharedExecutors {
30 36
37 + // TODO: make this configurable via setPoolSize static method
31 private static int numberOfThreads = 30; 38 private static int numberOfThreads = 30;
32 39
33 private static ExecutorService singleThreadExecutor = 40 private static ExecutorService singleThreadExecutor =
34 - Executors.newSingleThreadExecutor(groupedThreads("onos/shared", "onos-single-executor")); 41 + newSingleThreadExecutor(groupedThreads("onos/shared",
42 + "onos-single-executor"));
35 43
36 private static ExecutorService poolThreadExecutor = 44 private static ExecutorService poolThreadExecutor =
37 - Executors.newFixedThreadPool(numberOfThreads, groupedThreads("onos/shared", "onos-pool-executor-%d")); 45 + newFixedThreadPool(numberOfThreads, groupedThreads("onos/shared",
38 - 46 + "onos-pool-executor-%d"));
39 - private static java.util.Timer sharedTimer =
40 - new java.util.Timer("onos-shared-timer");
41 -
42 47
48 + private static Timer sharedTimer = new Timer("onos-shared-timer");
43 49
50 + // Ban public construction
44 private SharedExecutors() { 51 private SharedExecutors() {
45 -
46 } 52 }
47 53
48 /** 54 /**
49 - * Returns the single thread executor. 55 + * Returns the shared single thread executor.
50 * 56 *
51 * @return shared single thread executor 57 * @return shared single thread executor
52 */ 58 */
53 public static ExecutorService getSingleThreadExecutor() { 59 public static ExecutorService getSingleThreadExecutor() {
54 return singleThreadExecutor; 60 return singleThreadExecutor;
55 } 61 }
62 +
56 /** 63 /**
57 - * Returns the pool thread executor. 64 + * Returns the shared thread pool executor.
58 * 65 *
59 * @return shared executor pool 66 * @return shared executor pool
60 */ 67 */
61 public static ExecutorService getPoolThreadExecutor() { 68 public static ExecutorService getPoolThreadExecutor() {
62 return poolThreadExecutor; 69 return poolThreadExecutor;
63 } 70 }
71 +
64 /** 72 /**
65 - * Returns the pool timer. 73 + * Returns the shared timer.
66 * 74 *
67 * @return shared timer 75 * @return shared timer
68 */ 76 */
69 - public static java.util.Timer getTimer() { 77 + public static Timer getTimer() {
70 return sharedTimer; 78 return sharedTimer;
71 } 79 }
72 80
73 -
74 -
75 -
76 } 81 }
......