diff --git a/akka-actor/src/main/java/org/jboss/netty/akka/util/HashedWheelTimer.java b/akka-actor/src/main/java/org/jboss/netty/akka/util/HashedWheelTimer.java index d0112ded79..6e54fa2233 100644 --- a/akka-actor/src/main/java/org/jboss/netty/akka/util/HashedWheelTimer.java +++ b/akka-actor/src/main/java/org/jboss/netty/akka/util/HashedWheelTimer.java @@ -482,10 +482,10 @@ public class HashedWheelTimer implements Timer { buf.append("deadline: "); if (remaining > 0) { buf.append(remaining); - buf.append(" ms later, "); + buf.append(" ns later, "); } else if (remaining < 0) { buf.append(-remaining); - buf.append(" ms ago, "); + buf.append(" ns ago, "); } else { buf.append("now, "); } diff --git a/akka-actor/src/main/scala/akka/dispatch/AbstractDispatcher.scala b/akka-actor/src/main/scala/akka/dispatch/AbstractDispatcher.scala index b7f2afc8f7..85094bfe3a 100644 --- a/akka-actor/src/main/scala/akka/dispatch/AbstractDispatcher.scala +++ b/akka-actor/src/main/scala/akka/dispatch/AbstractDispatcher.scala @@ -137,7 +137,7 @@ abstract class MessageDispatcher(val prerequisites: DispatcherPrerequisites) ext shutdownScheduleUpdater.get(this) match { case UNSCHEDULED ⇒ if (shutdownScheduleUpdater.compareAndSet(this, UNSCHEDULED, SCHEDULED)) { - scheduler.scheduleOnce(shutdownTimeout, shutdownAction) + scheduleShutdownAction() () } else ifSensibleToDoSoThenScheduleShutdown() case SCHEDULED ⇒ @@ -148,6 +148,13 @@ abstract class MessageDispatcher(val prerequisites: DispatcherPrerequisites) ext case _ ⇒ () } + private def scheduleShutdownAction(): Unit = { + // IllegalStateException is thrown if scheduler has been shutdown + try scheduler.scheduleOnce(shutdownTimeout, shutdownAction) catch { + case _: IllegalStateException ⇒ shutdown() + } + } + private final val taskCleanup: () ⇒ Unit = () ⇒ if (inhabitantsUpdater.decrementAndGet(this) == 0) ifSensibleToDoSoThenScheduleShutdown() @@ -185,9 +192,7 @@ abstract class MessageDispatcher(val prerequisites: DispatcherPrerequisites) ext } case RESCHEDULED ⇒ if (shutdownScheduleUpdater.compareAndSet(MessageDispatcher.this, RESCHEDULED, SCHEDULED)) - try scheduler.scheduleOnce(shutdownTimeout, this) catch { - case _: IllegalStateException ⇒ shutdown() - } + scheduleShutdownAction() else run() } } @@ -279,9 +284,10 @@ abstract class MessageDispatcherConfigurator() { } } - def configureThreadPool(config: Config, - settings: Settings, - createDispatcher: ⇒ (ThreadPoolConfig) ⇒ MessageDispatcher): ThreadPoolConfigDispatcherBuilder = { + def configureThreadPool( + config: Config, + settings: Settings, + createDispatcher: ⇒ (ThreadPoolConfig) ⇒ MessageDispatcher): ThreadPoolConfigDispatcherBuilder = { import ThreadPoolConfigDispatcherBuilder.conf_? //Apply the following options to the config if they are present in the config