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:
parent
ed4e302d2a
commit
1755aedb58
4 changed files with 57 additions and 23 deletions
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue