ask 2.2
This commit is contained in:
parent
4270b6f71b
commit
0558e11aff
3 changed files with 10 additions and 10 deletions
|
|
@ -289,7 +289,7 @@ class ActorSystemImpl(val name: String, applicationConfig: Config) extends Actor
|
|||
|
||||
private[akka] def systemActorOf(props: Props, name: String): ActorRef = {
|
||||
implicit val timeout = settings.CreationTimeout
|
||||
Await.result(systemGuardian ? CreateChild(props, name), timeout.duration) match {
|
||||
Await.result(Futures.ask(systemGuardian, CreateChild(props, name)), timeout.duration) match {
|
||||
case ref: ActorRef ⇒ ref
|
||||
case ex: Exception ⇒ throw ex
|
||||
}
|
||||
|
|
@ -297,7 +297,7 @@ class ActorSystemImpl(val name: String, applicationConfig: Config) extends Actor
|
|||
|
||||
def actorOf(props: Props, name: String): ActorRef = {
|
||||
implicit val timeout = settings.CreationTimeout
|
||||
Await.result(guardian ? CreateChild(props, name), timeout.duration) match {
|
||||
Await.result(Futures.ask(guardian, CreateChild(props, name)), timeout.duration) match {
|
||||
case ref: ActorRef ⇒ ref
|
||||
case ex: Exception ⇒ throw ex
|
||||
}
|
||||
|
|
@ -305,7 +305,7 @@ class ActorSystemImpl(val name: String, applicationConfig: Config) extends Actor
|
|||
|
||||
def actorOf(props: Props): ActorRef = {
|
||||
implicit val timeout = settings.CreationTimeout
|
||||
Await.result(guardian ? CreateRandomNameChild(props), timeout.duration) match {
|
||||
Await.result(Futures.ask(guardian, CreateRandomNameChild(props)), timeout.duration) match {
|
||||
case ref: ActorRef ⇒ ref
|
||||
case ex: Exception ⇒ throw ex
|
||||
}
|
||||
|
|
@ -317,8 +317,8 @@ class ActorSystemImpl(val name: String, applicationConfig: Config) extends Actor
|
|||
val guard = guardian.path
|
||||
val sys = systemGuardian.path
|
||||
path.parent match {
|
||||
case `guard` ⇒ Await.result(guardian ? StopChild(actor), timeout.duration)
|
||||
case `sys` ⇒ Await.result(systemGuardian ? StopChild(actor), timeout.duration)
|
||||
case `guard` ⇒ Await.result(Futures.ask(guardian, StopChild(actor)), timeout.duration)
|
||||
case `sys` ⇒ Await.result(Futures.ask(systemGuardian, StopChild(actor)), timeout.duration)
|
||||
case _ ⇒ actor.asInstanceOf[InternalActorRef].stop()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -398,15 +398,15 @@ object TypedActor extends ExtensionId[TypedActorExtension] with ExtensionIdProvi
|
|||
case _ ⇒
|
||||
MethodCall(method, args) match {
|
||||
case m if m.isOneWay ⇒ actor ! m; null //Null return value
|
||||
case m if m.returnsFuture_? ⇒ actor.?(m, timeout)
|
||||
case m if m.returnsFuture_? ⇒ Futures.ask(actor, m)(timeout)
|
||||
case m if m.returnsJOption_? || m.returnsOption_? ⇒
|
||||
val f = actor.?(m, timeout)
|
||||
val f = Futures.ask(actor, m)(timeout)
|
||||
(try { Await.ready(f, timeout.duration).value } catch { case _: TimeoutException ⇒ None }) match {
|
||||
case None | Some(Right(null)) ⇒ if (m.returnsJOption_?) JOption.none[Any] else None
|
||||
case Some(Right(joption: AnyRef)) ⇒ joption
|
||||
case Some(Left(ex)) ⇒ throw ex
|
||||
}
|
||||
case m ⇒ Await.result(actor.?(m, timeout), timeout.duration).asInstanceOf[AnyRef]
|
||||
case m ⇒ Await.result(Futures.ask(actor, m)(timeout), timeout.duration).asInstanceOf[AnyRef]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import akka.util.Timeout
|
|||
import java.util.concurrent.atomic.AtomicInteger
|
||||
import scala.util.control.NoStackTrace
|
||||
import java.util.concurrent.TimeoutException
|
||||
import akka.dispatch.Await
|
||||
import akka.dispatch.{ Await, Futures }
|
||||
|
||||
object LoggingBus {
|
||||
implicit def fromActorSystem(system: ActorSystem): LoggingBus = system.eventStream
|
||||
|
|
@ -158,7 +158,7 @@ trait LoggingBus extends ActorEventBus {
|
|||
val name = "log" + Extension(system).id() + "-" + simpleName(clazz)
|
||||
val actor = system.systemActorOf(Props(clazz), name)
|
||||
implicit val timeout = Timeout(3 seconds)
|
||||
val response = try Await.result(actor ? InitializeLogger(this), timeout.duration) catch {
|
||||
val response = try Await.result(Futures.ask(actor, InitializeLogger(this)), timeout.duration) catch {
|
||||
case _: TimeoutException ⇒
|
||||
publish(Warning(simpleName(this), "Logger " + name + " did not respond within " + timeout + " to InitializeLogger(bus)"))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue