diff --git a/akka-actor/src/main/resources/reference.conf b/akka-actor/src/main/resources/reference.conf index 1d00474462..63f6cc21d9 100644 --- a/akka-actor/src/main/resources/reference.conf +++ b/akka-actor/src/main/resources/reference.conf @@ -36,6 +36,7 @@ akka { actor { provider = "akka.actor.LocalActorRefProvider" + creation-timeout = 20s # Timeout for ActorSystem.actorOf timeout = 5s # Default timeout for Future based invocations # - Actor: ask && ? # - UntypedActor: ask diff --git a/akka-actor/src/main/scala/akka/actor/ActorRefProvider.scala b/akka-actor/src/main/scala/akka/actor/ActorRefProvider.scala index 2fae75983c..91c3115c32 100644 --- a/akka-actor/src/main/scala/akka/actor/ActorRefProvider.scala +++ b/akka-actor/src/main/scala/akka/actor/ActorRefProvider.scala @@ -562,8 +562,8 @@ class LocalDeathWatch extends DeathWatch with ActorClassification { * Scheduled tasks (Runnable and functions) are executed with the supplied dispatcher. * Note that dispatcher is by-name parameter, because dispatcher might not be initialized * when the scheduler is created. - * - * The HashedWheelTimer used by this class MUST throw an IllegalStateException + * + * The HashedWheelTimer used by this class MUST throw an IllegalStateException * if it does not enqueue a task. Once a task is queued, it MUST be executed or * returned from stop(). */ diff --git a/akka-actor/src/main/scala/akka/actor/ActorSystem.scala b/akka-actor/src/main/scala/akka/actor/ActorSystem.scala index 130bdca85e..dff9042b8f 100644 --- a/akka-actor/src/main/scala/akka/actor/ActorSystem.scala +++ b/akka-actor/src/main/scala/akka/actor/ActorSystem.scala @@ -71,6 +71,7 @@ object ActorSystem { val ProviderClass = getString("akka.actor.provider") + val CreationTimeout = Timeout(Duration(getMilliseconds("akka.actor.creation-timeout"), MILLISECONDS)) val ActorTimeout = Timeout(Duration(getMilliseconds("akka.actor.timeout"), MILLISECONDS)) val SerializeAllMessages = getBoolean("akka.actor.serialize-messages") @@ -300,19 +301,21 @@ class ActorSystemImpl(val name: String, applicationConfig: Config) extends Actor protected def systemImpl = this - implicit def timeout = settings.ActorTimeout - - private[akka] def systemActorOf(props: Props, name: String): ActorRef = + private[akka] def systemActorOf(props: Props, name: String): ActorRef = { + implicit val timeout = settings.CreationTimeout (systemGuardian ? CreateChild(props, name)).get match { case ref: ActorRef ⇒ ref case ex: Exception ⇒ throw ex } + } - def actorOf(props: Props, name: String): ActorRef = + def actorOf(props: Props, name: String): ActorRef = { + implicit val timeout = settings.CreationTimeout (guardian ? CreateChild(props, name)).get match { case ref: ActorRef ⇒ ref case ex: Exception ⇒ throw ex } + } import settings._ @@ -398,7 +401,7 @@ class ActorSystemImpl(val name: String, applicationConfig: Config) extends Actor * Create the scheduler service. This one needs one special behavior: if * Closeable, it MUST execute all outstanding tasks upon .close() in order * to properly shutdown all dispatchers. - * + * * Furthermore, this timer service MUST throw IllegalStateException if it * cannot schedule a task. Once scheduled, the task MUST be executed. If * executed upon close(), the task may execute before its timeout. diff --git a/akka-actor/src/main/scala/akka/actor/Scheduler.scala b/akka-actor/src/main/scala/akka/actor/Scheduler.scala index 121b0da181..19697921fd 100644 --- a/akka-actor/src/main/scala/akka/actor/Scheduler.scala +++ b/akka-actor/src/main/scala/akka/actor/Scheduler.scala @@ -14,15 +14,15 @@ package akka.actor import akka.util.Duration - /** - * An Akka scheduler service. This one needs one special behavior: if - * Closeable, it MUST execute all outstanding tasks upon .close() in order - * to properly shutdown all dispatchers. - * - * Furthermore, this timer service MUST throw IllegalStateException if it - * cannot schedule a task. Once scheduled, the task MUST be executed. If - * executed upon close(), the task may execute before its timeout. - */ +/** + * An Akka scheduler service. This one needs one special behavior: if + * Closeable, it MUST execute all outstanding tasks upon .close() in order + * to properly shutdown all dispatchers. + * + * Furthermore, this timer service MUST throw IllegalStateException if it + * cannot schedule a task. Once scheduled, the task MUST be executed. If + * executed upon close(), the task may execute before its timeout. + */ trait Scheduler { /** * Schedules a message to be sent repeatedly with an initial delay and frequency.