mirror of
https://github.com/enso-org/enso.git
synced 2024-11-25 10:43:02 +03:00
Keep scheduled execution job on text edit (#6354)
close #6346 Changelog: - fix: keep scheduled execution job in the queue when applying a text edit
This commit is contained in:
parent
f288198b4b
commit
8c9c2d79cd
@ -27,10 +27,13 @@ class EditFileCmd(request: Api.EditFileNotification) extends Command(None) {
|
||||
val edits =
|
||||
request.edits.map(edit => PendingEdit.ApplyEdit(edit, request.execute))
|
||||
ctx.state.pendingEdits.enqueue(request.path, edits)
|
||||
ctx.jobControlPlane.abortAllJobs()
|
||||
ctx.jobProcessor.run(new EnsureCompiledJob(Seq(request.path)))
|
||||
if (request.execute) {
|
||||
ctx.jobControlPlane.abortAllJobs()
|
||||
ctx.jobProcessor.run(new EnsureCompiledJob(Seq(request.path)))
|
||||
executeJobs.foreach(ctx.jobProcessor.run)
|
||||
} else {
|
||||
ctx.jobControlPlane.abortAllExcept(classOf[ExecuteJob])
|
||||
ctx.jobProcessor.run(new EnsureCompiledJob(Seq(request.path)))
|
||||
}
|
||||
Future.successful(())
|
||||
} finally {
|
||||
|
@ -1,15 +1,22 @@
|
||||
package org.enso.interpreter.instrument.execution
|
||||
|
||||
import org.enso.interpreter.instrument.job.Job
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
/** Controls running jobs.
|
||||
*/
|
||||
trait JobControlPlane {
|
||||
|
||||
/** Aborts all interruptible jobs.
|
||||
*/
|
||||
/** Aborts all interruptible jobs. */
|
||||
def abortAllJobs(): Unit
|
||||
|
||||
/** Abort all jobs except the ignored jobs.
|
||||
*
|
||||
* @param ignoredJobs the list of jobs to keep in the execution queue
|
||||
*/
|
||||
def abortAllExcept(ignoredJobs: Class[_ <: Job[_]]*): Unit
|
||||
|
||||
/** Aborts all jobs that relates to the specified execution context.
|
||||
*
|
||||
* @param contextId an identifier of a context
|
||||
|
@ -128,9 +128,17 @@ final class JobExecutionEngine(
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
override def abortAllJobs(): Unit = {
|
||||
val allJobs = runningJobsRef.updateAndGet(_.filterNot(_.future.isCancelled))
|
||||
val cancellableJobs = allJobs.filter(_.job.isCancellable)
|
||||
override def abortAllJobs(): Unit =
|
||||
abortAllExcept()
|
||||
|
||||
/** @inheritdoc */
|
||||
override def abortAllExcept(ignoredJobs: Class[_ <: Job[_]]*): Unit = {
|
||||
val allJobs = runningJobsRef.updateAndGet(_.filterNot(_.future.isCancelled))
|
||||
val cancellableJobs = allJobs
|
||||
.filter { runningJob =>
|
||||
runningJob.job.isCancellable &&
|
||||
!ignoredJobs.contains(runningJob.job.getClass)
|
||||
}
|
||||
cancellableJobs.foreach { runningJob =>
|
||||
runningJob.future.cancel(runningJob.job.mayInterruptIfRunning)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user