Skip to content

Commit 121d530

Browse files
committed
Address review comment
1 parent 12662aa commit 121d530

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

src/main/scala/viper/server/frontends/lsp/file/Verification.scala

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,18 @@ trait VerificationManager extends ManagesLeaf {
9696
if (neverParsed) {
9797
runParseTypecheck(content)
9898
}
99-
futureAst.map(_.map(_ => this.synchronized(f))).getOrElse(Future.successful(this.synchronized(f)))
99+
// Delay the future since `futureAst` returns a future from `watchCompletion` which states:
100+
// "Note that this only means the elements have been passed downstream, not that downstream has successfully processed them."
101+
val future = futureAst.map(_.andThen(delay(10)(_))).getOrElse(Future.successful(()))
102+
future.map(_ => this.synchronized(f))
103+
}
104+
105+
private val system = akka.actor.ActorSystem("delayer")
106+
def delay[T](ms: Int)(block: => T): Future[T] = {
107+
import scala.concurrent.duration._
108+
akka.pattern.after(ms.millis, system.scheduler) {
109+
Future(block)
110+
}
100111
}
101112

102113
//other

src/main/scala/viper/server/vsi/VerificationServer.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,12 @@ trait VerificationServer extends Post {
166166
}
167167

168168
protected def discardAstOnCompletion(jid: AstJobId): Option[Future[Unit]] = {
169-
ast_jobs.lookupJob(jid).map(_.map(astHandle => astHandle.queue.watchCompletion().onComplete(_ => {
169+
ast_jobs.lookupJob(jid).map({job =>
170170
ast_jobs.discardJob(jid)
171-
astHandle.job_actor ! PoisonPill
172-
})))
171+
job.map(astHandle => astHandle.queue.watchCompletion().onComplete(_ => {
172+
astHandle.job_actor ! PoisonPill
173+
}))
174+
})
173175
}
174176

175177
/** This method starts a verification process.

0 commit comments

Comments
 (0)