diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/actors/scala/actors/FJTaskRunnerGroup.java | 26 | ||||
-rw-r--r-- | src/actors/scala/actors/FJTaskScheduler2.scala | 5 | ||||
-rw-r--r-- | src/actors/scala/actors/Scheduler.scala | 2 |
3 files changed, 15 insertions, 18 deletions
diff --git a/src/actors/scala/actors/FJTaskRunnerGroup.java b/src/actors/scala/actors/FJTaskRunnerGroup.java index 1120dd1f54..5485817614 100644 --- a/src/actors/scala/actors/FJTaskRunnerGroup.java +++ b/src/actors/scala/actors/FJTaskRunnerGroup.java @@ -161,25 +161,25 @@ public class FJTaskRunnerGroup implements IFJTaskRunnerGroup { /* -------- Suspending -------- */ - void snapshot() throws InterruptedException { - // set flag in all task runners to suspend - for (int i = 0; i < threads.length; ++i) { - FJTaskRunner t = threads[i]; - t.setSuspending(true); - } - - // interrupt all task runners - // assume: current thread not in threads (scheduler) - for (int i = 0; i < threads.length; ++i) { - Thread t = threads[i]; - t.interrupt(); + LinkedQueue snapshot() throws InterruptedException { + synchronized (this) { + for (int i = 0; i < threads.length; ++i) { + FJTaskRunner t = threads[i]; + // set flag in all task runners to suspend + t.setSuspending(true); + // interrupt all task runners + // assume: current thread not in threads (scheduler) + t.interrupt(); + } } // wait until all of them have terminated for (int i = 0; i < threads.length; ++i) { Thread t = threads[i]; t.join(); - } + }; + + return entryQueue; } /** diff --git a/src/actors/scala/actors/FJTaskScheduler2.scala b/src/actors/scala/actors/FJTaskScheduler2.scala index 934ccefaa8..fb34081c20 100644 --- a/src/actors/scala/actors/FJTaskScheduler2.scala +++ b/src/actors/scala/actors/FJTaskScheduler2.scala @@ -210,12 +210,9 @@ class FJTaskScheduler2 extends Thread with IScheduler { TimerThread.shutdown() } - def snapshot(): LinkedQueue = synchronized { + def snapshot(): LinkedQueue = { suspending = true executor.snapshot() - // grab tasks from executor - executor.entryQueue } - } diff --git a/src/actors/scala/actors/Scheduler.scala b/src/actors/scala/actors/Scheduler.scala index 73d40bea48..8396c20f47 100644 --- a/src/actors/scala/actors/Scheduler.scala +++ b/src/actors/scala/actors/Scheduler.scala @@ -42,7 +42,7 @@ object Scheduler { private var tasks: LinkedQueue = null private var pendingCount = 0 - def snapshot(): Unit = synchronized { + def snapshot(): Unit = { tasks = sched.snapshot() pendingCount = sched.asInstanceOf[FJTaskScheduler2].getPendingCount sched.shutdown() |