diff options
Diffstat (limited to 'src/actors/scala/actors/scheduler/DelegatingScheduler.scala')
-rw-r--r-- | src/actors/scala/actors/scheduler/DelegatingScheduler.scala | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/actors/scala/actors/scheduler/DelegatingScheduler.scala b/src/actors/scala/actors/scheduler/DelegatingScheduler.scala index b25e3d26f5..434911c48d 100644 --- a/src/actors/scala/actors/scheduler/DelegatingScheduler.scala +++ b/src/actors/scala/actors/scheduler/DelegatingScheduler.scala @@ -48,7 +48,22 @@ private[actors] trait DelegatingScheduler extends IScheduler { } } - def newActor(actor: Reactor) = impl.newActor(actor) + def newActor(actor: Reactor) = synchronized { + val createNew = if (sched eq null) + true + else sched.synchronized { + if (!sched.isActive) + true + else { + sched.newActor(actor) + false + } + } + if (createNew) { + sched = makeNewScheduler() + sched.newActor(actor) + } + } def terminated(actor: Reactor) = impl.terminated(actor) |