Make the code more explicit.
Change-Id: I2933d437f974e3329fb9484035c8a1753063c1a2
diff --git a/core/net/src/main/java/org/onosproject/event/impl/CoreEventDispatcher.java b/core/net/src/main/java/org/onosproject/event/impl/CoreEventDispatcher.java
index 58c26c4..6d0fa50 100644
--- a/core/net/src/main/java/org/onosproject/event/impl/CoreEventDispatcher.java
+++ b/core/net/src/main/java/org/onosproject/event/impl/CoreEventDispatcher.java
@@ -114,7 +114,7 @@
public void activate() {
if (maxProcessMillis != 0) {
- dispatchers.forEach(DispatchLoop::startWatchdog);
+ dispatchers.forEach(DispatchLoop::start);
}
log.info("Started");
@@ -166,7 +166,6 @@
groupedThreads("onos/event",
"dispatch-" + name + "%d", log));
eventsQueue = new LinkedBlockingQueue<>();
- dispatchFuture = executor.submit(this);
}
public boolean add(Event event) {
@@ -175,7 +174,6 @@
@Override
public void run() {
- stopped = false;
log.info("Dispatch loop({}) initiated", name);
while (!stopped) {
try {
@@ -211,11 +209,16 @@
void stop() {
stopped = true;
add(KILL_PILL);
+ if (null != dispatchFuture) {
+ dispatchFuture.cancel(true);
+ }
+ stopWatchdog();
}
- void restart() {
- dispatchFuture.cancel(true);
+ void start() {
+ stopped = false;
dispatchFuture = executor.submit(this);
+ startWatchdog();
}
// Monitors event sinks to make sure none take too long to execute.
@@ -235,7 +238,7 @@
// Cancel the old dispatch loop and submit a new one.
stop();
- restart();
+ start();
}
}
}