diff options
author | Martin Odersky <odersky@gmail.com> | 2011-02-04 15:52:19 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2011-02-04 15:52:19 +0000 |
commit | abb43ce593acacbfb68126fc892a18eda1148ad3 (patch) | |
tree | 3318dfaefd0b91d71272175b591420ba24196db9 /src | |
parent | d8f00482ff9d4233b892bba88f69c4142e3fc66a (diff) | |
download | scala-abb43ce593acacbfb68126fc892a18eda1148ad3.tar.gz scala-abb43ce593acacbfb68126fc892a18eda1148ad3.tar.bz2 scala-abb43ce593acacbfb68126fc892a18eda1148ad3.zip |
Presentation compiler yields now to be nicer to...
Presentation compiler yields now to be nicer to UI thread.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/interactive/Global.scala | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index e4befdc1dd..033776e7eb 100644 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -208,12 +208,24 @@ self => var moreWorkAtNode: Int = -1 var nodesSeen = 0 + /** The number of pollForWorks after which the presentation compiler yields. + * Yielding improves responsiveness on systems with few cores because it + * gives the UI thread a chance to get new tasks and interrupt the presentation + * compiler with them. + */ + final val yieldPeriod = 8 + /** Called from runner thread and signalDone: * Poll for interrupts and execute them immediately. * Then, poll for exceptions and execute them. * Then, poll for work reload/typedTreeAt/doFirst commands during background checking. + * @param pos The position of the tree if polling while typechecking, NoPosition otherwise + * */ def pollForWork(pos: Position) { + if (pos == NoPosition || nodesSeen % yieldPeriod == 0) + Thread.`yield`() + def nodeWithWork(): Option[WorkEvent] = if (scheduler.moreWork || pendingResponse.isCancelled) Some(new WorkEvent(nodesSeen, System.currentTimeMillis)) else None |