Implementation of the new daemon management without inter-daemon elections and with few other simplifications

Original commit: 375679677c
This commit is contained in:
Ilya Chernikov
2015-11-09 19:51:07 +01:00
parent 84fea1a41d
commit b58eb87771
@@ -132,7 +132,7 @@ public object KotlinCompilerRunner {
}
internal class DaemonConnection(public val daemon: CompileService?)
internal class DaemonConnection(public val daemon: CompileService?, public val sessionId: Int = CompileService.NO_SESSION)
internal object getDaemonConnection {
private @Volatile var connection: DaemonConnection? = null
@@ -153,9 +153,13 @@ public object KotlinCompilerRunner {
val profiler = if (daemonOptions.reportPerf) WallAndThreadAndMemoryTotalProfiler(withGC = false) else DummyProfiler()
profiler.withMeasure(null) {
connection = DaemonConnection(
KotlinCompilerClient.connectToCompileService(compilerId, daemonJVMOptions, daemonOptions, DaemonReportingTargets(null, daemonReportMessages), true, true)
)
fun newFlagFile(): File {
val flagFile = File.createTempFile("kotlin-compiler-jps-session-", "-is-running")
flagFile.deleteOnExit()
return flagFile
}
val daemon = KotlinCompilerClient.connectToCompileService(compilerId, daemonJVMOptions, daemonOptions, DaemonReportingTargets(null, daemonReportMessages), true, true)
connection = DaemonConnection(daemon, daemon?.leaseCompileSession(newFlagFile().absolutePath)?.get() ?:CompileService.NO_SESSION)
}
for (msg in daemonReportMessages) {
@@ -196,7 +200,7 @@ public object KotlinCompilerRunner {
K2JS_COMPILER -> CompileService.TargetPlatform.JS
else -> throw IllegalArgumentException("Unknown compiler type $compilerClassName")
}
val res = KotlinCompilerClient.incrementalCompile(connection!!.daemon!!, targetPlatform, argsArray, services, compilerOut, daemonOut)
val res = KotlinCompilerClient.incrementalCompile(connection!!.daemon!!, connection.sessionId, targetPlatform, argsArray, services, compilerOut, daemonOut)
processCompilerOutput(messageCollector, collector, compilerOut, res.toString())
BufferedReader(StringReader(daemonOut.toString())).forEachLine {