#2970 - Removing scheduler and dispatcher from ARP and reimplementing PromiseActorRef to use an internal calling thread EC
This commit is contained in:
parent
88f7e28c6b
commit
fcfe7b4617
15 changed files with 69 additions and 88 deletions
|
|
@ -88,8 +88,7 @@ final class AskableActorRef(val actorRef: ActorRef) extends AnyVal {
|
|||
case ref: InternalActorRef ⇒
|
||||
if (timeout.duration.length <= 0) Future.failed[Any](new IllegalArgumentException("Timeout length for an `ask` must be greater or equal to 1. Question not sent to [%s]" format actorRef))
|
||||
else {
|
||||
val provider = ref.provider
|
||||
val a = PromiseActorRef(provider, timeout)
|
||||
val a = PromiseActorRef(ref.provider, timeout)
|
||||
actorRef.tell(message, a)
|
||||
a.result.future
|
||||
}
|
||||
|
|
@ -166,6 +165,9 @@ private[akka] final class PromiseActorRef private (val provider: ActorRefProvide
|
|||
|
||||
override def getParent: InternalActorRef = provider.tempContainer
|
||||
|
||||
def internalCallingThreadExecutionContext: ExecutionContext =
|
||||
provider.guardian.underlying.systemImpl.internalCallingThreadExecutionContext
|
||||
|
||||
/**
|
||||
* Contract of this method:
|
||||
* Must always return the same ActorPath, which must have
|
||||
|
|
@ -250,10 +252,11 @@ private[akka] object PromiseActorRef {
|
|||
private case class StoppedWithPath(path: ActorPath)
|
||||
|
||||
def apply(provider: ActorRefProvider, timeout: Timeout): PromiseActorRef = {
|
||||
implicit val ec = provider.dispatcher // TODO should we take an ExecutionContext in the method signature?
|
||||
val result = Promise[Any]()
|
||||
val scheduler = provider.guardian.underlying.system.scheduler
|
||||
val a = new PromiseActorRef(provider, result)
|
||||
val f = provider.scheduler.scheduleOnce(timeout.duration) { result tryComplete Failure(new AskTimeoutException("Timed out")) }
|
||||
implicit val ec = a.internalCallingThreadExecutionContext
|
||||
val f = scheduler.scheduleOnce(timeout.duration) { result tryComplete Failure(new AskTimeoutException("Timed out")) }
|
||||
result.future onComplete { _ ⇒ try a.stop() finally f.cancel() }
|
||||
a
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue