make scheduler shutdown more stringent

- run closeScheduler upon ActorSystem termination (directly)
- this will execute all outstanding tasks (dispatcher shutdowns have
  been queued already, because the last actor has already exited)
- further use of the scheduler (e.g. from tasks just being run) results
  in IllegalStateException
- catch such exceptions in DefaultPromise&MessageDispatcher in case of
  self-rescheduling tasks and execute final action immediately
- also silently stop recurring tasks
This commit is contained in:
Roland 2011-12-03 21:26:32 +01:00
parent ed4e302d2a
commit 1755aedb58
4 changed files with 57 additions and 23 deletions

View file

@ -212,7 +212,9 @@ abstract class MessageDispatcher(val prerequisites: DispatcherPrerequisites) ext
}
case RESCHEDULED
if (shutdownScheduleUpdater.compareAndSet(MessageDispatcher.this, RESCHEDULED, SCHEDULED))
scheduler.scheduleOnce(this, shutdownTimeout)
try scheduler.scheduleOnce(this, shutdownTimeout) catch {
case _: IllegalStateException shutdown()
}
else run()
}
}