File tree Expand file tree Collapse file tree
src/main/scala/viper/server Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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.
You can’t perform that action at this time.
0 commit comments