diff options
author | Philipp Haller <hallerp@gmail.com> | 2009-05-24 19:30:39 +0000 |
---|---|---|
committer | Philipp Haller <hallerp@gmail.com> | 2009-05-24 19:30:39 +0000 |
commit | 67ab4b8ece5e83575c63a58dd668ff662b5dc7eb (patch) | |
tree | c5c9e21cc3ff019090a154ca2d2212ac986a96af /src/actors/scala/actors/IScheduler.scala | |
parent | a1f098795934a4ccc8a3e72b779e47b911eae0f4 (diff) | |
download | scala-67ab4b8ece5e83575c63a58dd668ff662b5dc7eb.tar.gz scala-67ab4b8ece5e83575c63a58dd668ff662b5dc7eb.tar.bz2 scala-67ab4b8ece5e83575c63a58dd668ff662b5dc7eb.zip |
Implemented #2012.
Diffstat (limited to 'src/actors/scala/actors/IScheduler.scala')
-rw-r--r-- | src/actors/scala/actors/IScheduler.scala | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/actors/scala/actors/IScheduler.scala b/src/actors/scala/actors/IScheduler.scala new file mode 100644 index 0000000000..dc2e6961fa --- /dev/null +++ b/src/actors/scala/actors/IScheduler.scala @@ -0,0 +1,66 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2009, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + +package scala.actors + +/** + * The <code>IScheduler</code> trait provides a common interface + * for all schedulers used to execute actor tasks. + * + * Subclasses of <code>Actor</code> that override its + * <code>scheduler</code> member must provide + * an implementation of the <code>IScheduler</code> + * trait. + * + * @author Philipp Haller + */ +trait IScheduler { + + /** Submits a closure for execution. + * + * @param fun the closure to be executed + */ + def execute(fun: => Unit): Unit + + /** Submits a <code>Runnable</code> for execution. + * + * @param task the task to be executed + */ + def execute(task: Runnable): Unit + + /** Shuts down the scheduler. + */ + def shutdown(): Unit + + /** When the scheduler is active, it can execute tasks. + */ + def isActive: Boolean + + /** Registers a newly created actor with this scheduler. + * + * @param a the actor to be registered + */ + def newActor(a: Actor): Unit + + /** Unregisters an actor from this scheduler, because it + * has terminated. + * + * @param a the actor to be registered + */ + def terminated(a: Actor): Unit + + /** Registers a closure to be executed when the specified + * actor terminates. + * + * @param a the actor + * @param f the closure to be registered + */ + def onTerminate(a: Actor)(f: => Unit): Unit +} |