diff options
Diffstat (limited to 'src/library/scala/concurrent/Actor.scala')
-rw-r--r-- | src/library/scala/concurrent/Actor.scala | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/library/scala/concurrent/Actor.scala b/src/library/scala/concurrent/Actor.scala new file mode 100644 index 0000000000..4ba4ab3078 --- /dev/null +++ b/src/library/scala/concurrent/Actor.scala @@ -0,0 +1,29 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2005, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + +package scala.concurrent; + +abstract class Actor extends Thread { + private val in = new MailBox; + + def send(msg: in.Message) = + in.send(msg); + + def receive[a](f: PartialFunction[in.Message, a]): a = + if (Thread.currentThread() == this) in.receive(f); + else error("receive called not on own process"); + + def receiveWithin[a](msec: long)(f: PartialFunction[in.Message, a]): a = + if (Thread.currentThread() == this) in.receiveWithin(msec)(f); + else error("receiveWithin called not on own process"); +} + + + |