Moving the timeout so that it isn't calculated unless the actor is running
This commit is contained in:
parent
df316b98de
commit
00e8fd79cb
1 changed files with 4 additions and 3 deletions
|
|
@ -1183,9 +1183,10 @@ trait ScalaActorRef extends ActorRefShared with ForwardableChannel { ref: ActorR
|
|||
* Sends a message asynchronously, returning a future which may eventually hold the reply.
|
||||
*/
|
||||
def ?(message: Any, timeout: Actor.Timeout = Actor.noTimeoutGiven)(implicit channel: UntypedChannel = NullChannel, implicitTimeout: Actor.Timeout = Actor.defaultTimeout): Future[Any] = {
|
||||
val realTimeout = if (timeout eq Actor.noTimeoutGiven) implicitTimeout else timeout
|
||||
if (isRunning) postMessageToMailboxAndCreateFutureResultWithTimeout(message, realTimeout.duration.toMillis, channel)
|
||||
else throw new ActorInitializationException(
|
||||
if (isRunning) {
|
||||
val realTimeout = if (timeout eq Actor.noTimeoutGiven) implicitTimeout else timeout
|
||||
postMessageToMailboxAndCreateFutureResultWithTimeout(message, realTimeout.duration.toMillis, channel)
|
||||
} else throw new ActorInitializationException(
|
||||
"Actor has not been started, you need to invoke 'actor.start()' before using it")
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue