From 46bb8d600c4f47e044c40583cb3f564761eab035 Mon Sep 17 00:00:00 2001 From: Miles Sabin Date: Tue, 26 May 2009 10:18:52 +0000 Subject: Export new packages; minor updates to interactive. --- src/compiler/scala/tools/nsc/interactive/Global.scala | 17 +++++++++-------- src/compiler/scala/tools/nsc/util/WorkScheduler.scala | 5 ++--- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index c912378385..ea2a396e09 100755 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -72,7 +72,7 @@ self => // ----------------- Polling --------------------------------------- - private var pollingEnabled = false + private var pollingEnabled = true /** Called from runner thread and singnalDone */ def pollForWork() { @@ -96,6 +96,9 @@ self => // ----------------- The Background Runner Thread ----------------------- + /* Must be initialized before starting compilerRunner */ + private val scheduler = new WorkScheduler + /** The current presentation compiler runner */ private var compileRunner = newRunnerThread compileRunner.start() @@ -185,16 +188,16 @@ self => // ----------------- Implementations of client commmands ----------------------- /** Make sure a set of compilation units is loaded and parsed */ - def reload(sources: Set[SourceFile]) = { + def reload(sources: Set[SourceFile], reloaded: SyncVar[Unit]) = { currentTyperRun = new TyperRun() for (source <- sources) { - val unit = new RichCompilationUnit(source) - unitOfFile(source.file) = unit + val unit = unitOf(source) currentTyperRun.compileLate(unit) unit.status = JustParsed } outOfDate = true moveToFront(sources.toList map (_.file)) + reloaded.set(()) if (compiling) throw new FreshRunReq } @@ -318,8 +321,6 @@ self => // ----------------- interface to IDE ------------------------------------ - private val scheduler = new WorkScheduler - /** The compilation unit corresponding to a source file */ def unitOf(s: SourceFile): RichCompilationUnit = unitOfFile get s.file match { case Some(unit) => @@ -342,8 +343,8 @@ self => locateContext(unitOf(pos).contexts, pos) /** Make sure a set of compilation units is loaded and parsed */ - def askReload(sources: Set[SourceFile]) = - scheduler.postWorkItem(() => reload(sources)) + def askReload(sources: Set[SourceFile], reloaded: SyncVar[Unit]) = + scheduler.postWorkItem(() => reload(sources, reloaded)) /** Set sync var `result` to a fully attributed tree located at position `pos` */ def askTypeAt(pos: Position, result: SyncVar[Tree]) = diff --git a/src/compiler/scala/tools/nsc/util/WorkScheduler.scala b/src/compiler/scala/tools/nsc/util/WorkScheduler.scala index cd4d805701..bcd57ba6c2 100644 --- a/src/compiler/scala/tools/nsc/util/WorkScheduler.scala +++ b/src/compiler/scala/tools/nsc/util/WorkScheduler.scala @@ -12,7 +12,7 @@ class WorkScheduler { /** Called from server: block until todo list is nonempty */ def waitForMoreWork() = synchronized { - do { wait() } while (todo.isEmpty) + while (todo.isEmpty) { wait() } } /** called from Server: test whether todo list is nonempty */ @@ -44,7 +44,7 @@ class WorkScheduler { } /** Called from client: have action executed by server */ - def postWorkItem(action: Action) { + def postWorkItem(action: Action) = synchronized { todo enqueue action notify() } @@ -62,4 +62,3 @@ class WorkScheduler { if (working) except = Some(exc) } } - -- cgit v1.2.3