Add locking in dispatchFuture
This commit is contained in:
parent
162d059112
commit
b05be42f11
1 changed files with 15 additions and 11 deletions
|
|
@ -78,18 +78,22 @@ trait MessageDispatcher extends Logging {
|
|||
} else throw new IllegalActorStateException("Can't submit invocations to dispatcher since it's not started")
|
||||
|
||||
private[akka] final def dispatchFuture(invocation: FutureInvocation): Unit = {
|
||||
futures add invocation.uuid
|
||||
if (active.isOff) { active.switchOn { start } }
|
||||
guard withGuard {
|
||||
futures add invocation.uuid
|
||||
if (active.isOff) { active.switchOn { start } }
|
||||
}
|
||||
invocation.future.onComplete { f =>
|
||||
futures remove invocation.uuid
|
||||
if (futures.isEmpty && uuids.isEmpty) {
|
||||
shutdownSchedule match {
|
||||
case UNSCHEDULED =>
|
||||
shutdownSchedule = SCHEDULED
|
||||
Scheduler.scheduleOnce(shutdownAction, timeoutMs, TimeUnit.MILLISECONDS)
|
||||
case SCHEDULED =>
|
||||
shutdownSchedule = RESCHEDULED
|
||||
case RESCHEDULED => //Already marked for reschedule
|
||||
guard withGuard {
|
||||
futures remove invocation.uuid
|
||||
if (futures.isEmpty && uuids.isEmpty) {
|
||||
shutdownSchedule match {
|
||||
case UNSCHEDULED =>
|
||||
shutdownSchedule = SCHEDULED
|
||||
Scheduler.scheduleOnce(shutdownAction, timeoutMs, TimeUnit.MILLISECONDS)
|
||||
case SCHEDULED =>
|
||||
shutdownSchedule = RESCHEDULED
|
||||
case RESCHEDULED => //Already marked for reschedule
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue