summaryrefslogtreecommitdiff
path: root/src/library/scala/concurrent/Actor.scala
blob: 4e15220a37102a83bef0bc66202c07f5cdb27cd7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*                     __                                               *\
**     ________ ___   / /  ___     Scala API                            **
**    / __/ __// _ | / /  / _ |    (c) 2003-2007, LAMP/EPFL             **
**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
** /____/\___/_/ |_/____/_/ | |                                         **
**                          |/                                          **
\*                                                                      */

// $Id$


package scala.concurrent

import java.lang.Thread

/**
 * The class <code>Actor</code> ...
 *
 * @author Martin Odersky
 * @version 1.0
 * @deprecated  use scala.actors package instead
 */
@deprecated
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 (currentThread == this) in.receive(f)
    else throw new IllegalArgumentException("receive called not on own process")

  def receiveWithin[a](msec: long)(f: PartialFunction[in.Message, a]): a =
    if (currentThread == this) in.receiveWithin(msec)(f)
    else throw new IllegalArgumentException("receiveWithin called not on own process")

  private var pid: Pid = null

  def self = {
    if (pid eq null) pid = new Pid(this)
    pid
  }

  def self_= (p: Pid) = pid = p
}