Skip to content

Instantly share code, notes, and snippets.

@gsimard
Created May 11, 2013 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gsimard/5559995 to your computer and use it in GitHub Desktop.
Save gsimard/5559995 to your computer and use it in GitHub Desktop.
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