Permalink
Browse files

LocalServer: better synchronization

  • Loading branch information...
1 parent 26025bd commit 7589f6992001fdc03cc6a74dbe78f5b0290b423d @pavelfatin pavelfatin committed Aug 30, 2013
@@ -139,14 +139,20 @@ object ScalaBuilder {
// Cached local localServer
private var cachedServer: Option[Server] = None
+ private val lock = new Object()
+
private def localServer = {
- val server = cachedServer.getOrElse(new LocalServer())
- cachedServer = Some(server)
- server
+ lock.synchronized {
+ val server = cachedServer.getOrElse(new LocalServer())
+ cachedServer = Some(server)
+ server
+ }
}
private def cleanLocalServerCache() {
- cachedServer = None
+ lock.synchronized {
+ cachedServer = None
+ }
}
private lazy val sbtData = {
@@ -22,12 +22,8 @@ class LocalServer extends Server {
}
if (!client.isCanceled) {
- client.progress("Waiting for a free compiler...")
-
- compiler.synchronized {
- client.progress("Searching for changed files...")
- compiler.compile(compilationData, client)
- }
+ client.progress("Searching for changed files...")
+ compiler.compile(compilationData, client)
}
ExitCode.OK

0 comments on commit 7589f69

Please sign in to comment.