Advertisement
Guest User

System

a guest
Mar 6th, 2014
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.64 KB | None | 0 0
  1. trait ActorsSystem {
  2.   protected val System: ActorSystem
  3.   protected val actors: Map[String, ActorRef]
  4.  
  5.   def apply(actorName: String) = {
  6.     actors(actorName)
  7.   }
  8.  
  9.   //Use the System's dispatcher as ExecutionContext
  10.   import System.dispatcher
  11.  
  12.   def schedule(delay: Int, event: Any) {
  13.     System.scheduler.scheduleOnce(delay seconds) {
  14.       this("sender") ! event
  15.     }
  16.   }
  17. }
  18.  
  19. object ActorsSystem extends ActorsSystem {
  20.   protected val System: ActorSystem = ActorSystem("System", Configuration.RawConfiguration)
  21.  
  22.   protected val actors: Map[String, ActorRef] = Map("event1" -> System.actorOf(BackendActor.event1Pool, "event1"),...)
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement