Skip to content

Commit

Permalink
Make sure the old presentation compiler thread is killed
Browse files Browse the repository at this point in the history
This is based on scalacenter/scalafix#1272

Previous solution did not actually kill the presentation compiler thread.
  • Loading branch information
tgodzik committed Feb 4, 2021
1 parent fc11dcf commit 0e5eb95
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package scala.tools.nsc.interactive

import java.util.logging.Level

import scala.tools.nsc.util.WorkScheduler
import scala.util.control.NonFatal

import scala.meta.internal.pc.MetalsGlobal
Expand Down Expand Up @@ -38,8 +39,8 @@ trait GlobalProxy { this: MetalsGlobal =>
private def newRunnerThread(): Thread = {
if (compileRunner.isAlive) {
try {
val re = askForResponse(() => throw ShutdownReq)
re.get
this.askShutdown()
while (compileRunner.isAlive) Thread.sleep(0)
} catch {
case NonFatal(e) =>
logger.log(
Expand All @@ -49,6 +50,7 @@ trait GlobalProxy { this: MetalsGlobal =>
)
}
}
this.scheduler = new WorkScheduler
compileRunner = new MetalsGlobalThread(this, "Metals")
compileRunner.setDaemon(true)
compileRunner.start()
Expand Down

0 comments on commit 0e5eb95

Please sign in to comment.