summaryrefslogtreecommitdiff
path: root/src/actors/scala/actors/Scheduler.scala
diff options
context:
space:
mode:
authorPhilipp Haller <hallerp@gmail.com>2009-07-20 15:28:34 +0000
committerPhilipp Haller <hallerp@gmail.com>2009-07-20 15:28:34 +0000
commit9fcf6dc3c6b32e03c64d340e285e1d7886593d20 (patch)
tree39b1fa5e251d62fba686e691e85316b9f11608eb /src/actors/scala/actors/Scheduler.scala
parent670edfe22a90dc08928b95e947b1a72c9ad463bf (diff)
downloadscala-9fcf6dc3c6b32e03c64d340e285e1d7886593d20.tar.gz
scala-9fcf6dc3c6b32e03c64d340e285e1d7886593d20.tar.bz2
scala-9fcf6dc3c6b32e03c64d340e285e1d7886593d20.zip
Re-enabled snapshot for new ForkJoinPool.
Diffstat (limited to 'src/actors/scala/actors/Scheduler.scala')
-rw-r--r--src/actors/scala/actors/Scheduler.scala55
1 files changed, 11 insertions, 44 deletions
diff --git a/src/actors/scala/actors/Scheduler.scala b/src/actors/scala/actors/Scheduler.scala
index d81a9d1bc5..d3dd27678b 100644
--- a/src/actors/scala/actors/Scheduler.scala
+++ b/src/actors/scala/actors/Scheduler.scala
@@ -10,14 +10,12 @@
package scala.actors
-import java.lang.Runnable
import java.util.concurrent._
/**
* The <code>Scheduler</code> object is used by <code>Actor</code> to
* execute tasks of an execution of an actor.
*
- * @version 0.9.18
* @author Philipp Haller
*/
object Scheduler extends DelegatingScheduler {
@@ -38,53 +36,22 @@ object Scheduler extends DelegatingScheduler {
s
}
- private var tasks: LinkedQueue = null
-
- /* Assumes <code>sched</code> holds an instance
- * of <code>FJTaskScheduler2</code>.
+ /* Only <code>ForkJoinScheduler</code> implements this method.
*/
- @deprecated def snapshot(): Unit = synchronized {
- if (sched.isInstanceOf[FJTaskScheduler2]) {
- val fjts = sched.asInstanceOf[FJTaskScheduler2]
- tasks = fjts.snapshot()
- fjts.shutdown()
+ @deprecated def snapshot() {
+ if (sched.isInstanceOf[ForkJoinScheduler]) {
+ sched.asInstanceOf[ForkJoinScheduler].snapshot()
} else
- error("snapshot operation not supported.")
+ error("scheduler does not implement snapshot")
}
- /** Shuts down the current scheduler and creates and starts a new scheduler.
- *
- * If the current scheduler is an <code>FJTaskScheduler2</code>
- * a new scheduler of the same class is created. In that case,
- * tasks resulting from a <code>snapshot</code> are
- * submitted for execution.
- *
- * If the current scheduler is not an <code>FJTaskScheduler2</code>,
- * a <code>DefaultExecutorScheduler</code> is created.
+ /* Only <code>ForkJoinScheduler</code> implements this method.
*/
- def restart(): Unit = synchronized {
- // 1. shut down current scheduler
- if (sched ne null) {
- sched.shutdown()
- }
-
- // 2. create and start new scheduler
- if ((sched ne null) && sched.isInstanceOf[FJTaskScheduler2]) {
- sched = {
- val s = new FJTaskScheduler2
- s.start()
- s
- }
- if (tasks != null) {
- while (!tasks.isEmpty()) {
- sched.execute(tasks.take().asInstanceOf[FJTask])
- }
- tasks = null
- }
- } else {
- // will trigger creation of new delegate scheduler
- sched = null
- }
+ @deprecated def restart() {
+ if (sched.isInstanceOf[ForkJoinScheduler]) {
+ sched.asInstanceOf[ForkJoinScheduler].restart()
+ } else
+ error("scheduler does not implement restart")
}
}