summaryrefslogtreecommitdiff
path: root/src/actors-migration/scala/actors/Pattern.scala
blob: 97dbd2cccd79e784b3414cfbffaab44c7fb14338 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package scala.actors

import scala.concurrent.util.Duration

object pattern {

  implicit def askSupport(ar: ActorRef): AskableActorRef =
    new AskableActorRef(ar)
}

/**
 * ActorRef with support for ask(?) operation.
 */
class AskableActorRef(val ar: ActorRef) extends ActorRef {

  def !(message: Any)(implicit sender: ActorRef = null): Unit = ar.!(message)(sender)

  def ?(message: Any)(timeout: Timeout): Future[Any] = ar.?(message, timeout.duration)

  private[actors] def ?(message: Any, timeout: Duration): Future[Any] = ar.?(message, timeout)

  def forward(message: Any) = ar.forward(message)

  private[actors] def localActor: AbstractActor = ar.localActor
}