fixed bug in 'actor' methods
This commit is contained in:
parent
8130e69331
commit
0c7deeee4f
2 changed files with 14 additions and 27 deletions
|
|
@ -32,6 +32,16 @@
|
|||
<artifactId>scala-library</artifactId>
|
||||
<version>${scala.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.aspectwerkz</groupId>
|
||||
<artifactId>aspectwerkz-nodeps-jdk5</artifactId>
|
||||
<version>2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.aspectwerkz</groupId>
|
||||
<artifactId>aspectwerkz-jdk5</artifactId>
|
||||
<version>2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.netty</groupId>
|
||||
<artifactId>netty</artifactId>
|
||||
|
|
|
|||
|
|
@ -171,33 +171,6 @@ object Actor extends Logging {
|
|||
def receive = body
|
||||
}
|
||||
|
||||
/**
|
||||
* Use to create an anonymous event-driven actor with both an init block and a message loop block
|
||||
* as well as a life-cycle configuration.
|
||||
* The actor is started when created.
|
||||
* Example:
|
||||
* <pre>
|
||||
* import Actor._
|
||||
*
|
||||
* val a = actor(LifeCycle(Temporary)) {
|
||||
* ... // init stuff
|
||||
* } receive {
|
||||
* case msg => ... // handle message
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
def actor[A](lifeCycleConfig: LifeCycle)(body: => Unit) = {
|
||||
def handler[A](body: Unit) = new {
|
||||
def receive(handler: PartialFunction[Any, Unit]) = new Actor() {
|
||||
lifeCycle = Some(lifeCycleConfig)
|
||||
start
|
||||
body
|
||||
def receive = handler
|
||||
}
|
||||
}
|
||||
handler(body)
|
||||
}
|
||||
|
||||
/**
|
||||
* Use to create an anonymous event-driven remote actor.
|
||||
* The actor is started when created.
|
||||
|
|
@ -216,6 +189,10 @@ object Actor extends Logging {
|
|||
def receive = body
|
||||
}
|
||||
|
||||
val a = actor(LifeCycle(Temporary)) {
|
||||
case "test" => println("received test")
|
||||
case _ => println("received unknown message")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue