Created
May 11, 2013 13:36
-
-
Save gsimard/5559995 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import akka.actor.ActorRef | |
/** | |
* Handle global reference to actor | |
* | |
* Usage: | |
* object MyGlobal extends GlobalActorRef(Actor.registry.actorFor[MyActor]) | |
* object MyGlobal extends GlobalActorRef(Some(Actor.remove.actorFor[MyActor])) | |
* | |
* @author teamon | |
*/ | |
abstract class GlobalActorRef(actorFun: => ActorRef) { | |
lazy val actor = actorFun | |
def apply() = actor | |
// HACK: This should be done with implicit conversion | |
def !(message: Any)(implicit sender: Option[ActorRef] = None) = actor ! message | |
//def !!(message: Any)(implicit sender: Option[ActorRef] = None) = actor !! message | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment