/
Reaction.scala
44 lines (36 loc) · 1.33 KB
/
Reaction.scala
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
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2005-2009, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.actors
import scala.util.control.ControlException
import java.lang.{InterruptedException, Runnable}
private[actors] class KillActorException extends Throwable with ControlException {
/*
* For efficiency reasons we do not fill in
* the execution stack trace.
*/
override def fillInStackTrace(): Throwable = this
}
/** <p>
* The abstract class <code>Reaction</code> associates
* an instance of an <code>Actor</code> with a
* <a class="java/lang/Runnable" href="" target="contentFrame">
* <code>java.lang.Runnable</code></a>.
* </p>
*
* @version 0.9.10
* @author Philipp Haller
*/
class Reaction(a: Actor, f: PartialFunction[Any, Unit], msg: Any) extends ActorTask(a, () => {
if (f == null)
a.act()
else
f(msg)
}) {
def this(a: Actor) = this(a, null, null)
}