Defer short-running jobs from the progress view#4131
Conversation
| } | ||
| }; | ||
| pendingJobAdditions.put(job, graceTimer); | ||
| display.asyncExec(() -> { |
There was a problem hiding this comment.
This can flood UI thread with asyncExec / timerExec tasks for short living jobs. I would not misuse UI thread to dispatch tasks just to make sure progress view don't show jobs.
There was a problem hiding this comment.
Reworked to avoid per-job UI dispatch: pendingJobAdditions is now a Map<Job, Long> of grace deadlines instead of per-job timers. Scheduling only puts the deadline in the map; notifyListeners() (the throttler's coalesced UI pass) drains and announces the expired entries, re-arming once via throttledAsyncExec() while any remain. Cancelling is a plain ConcurrentHashMap.remove, no dispatch.
| return false; | ||
| } | ||
| if (display != null && !display.isDisposed()) { | ||
| display.asyncExec(() -> display.timerExec(-1, pending)); |
There was a problem hiding this comment.
Same fix: cancelling is now just pendingJobAdditions.remove(job), no asyncExec/timerExec.
Non-system jobs were shown in the progress view the moment they were scheduled and removed when they finished, so jobs that complete within a few hundred milliseconds flashed in and out and could not be read. Add a per-job grace period before a job is announced to the progress listeners. Jobs that finish, sleep or are cancelled before the grace period elapses are never shown, which removes the flicker for refresh, validation and decoration bursts. The grace period defaults to half of getLongOperationTime() with a lower bound of 200ms and can be overridden through the org.eclipse.ui.progress.viewGracePeriod system property. Jobs kept after completion (KEEP_PROPERTY or an error result) are still captured. Fixes eclipse-platform#4126
7f66863 to
382bc50
Compare
The progress view added a job the moment it was scheduled and removed it when it finished, so jobs that complete within a few hundred milliseconds flashed in and out and could not be read (very noticeable with system jobs enabled).
This adds a per-job grace period before a job is announced to the progress listeners. Jobs that finish, sleep or are cancelled before the grace period elapses are never shown, which removes the flicker for refresh, validation and decoration bursts. The grace period defaults to half of
getLongOperationTime()with a 200ms floor and can be overridden through theorg.eclipse.ui.progress.viewGracePeriodsystem property. Jobs kept after completion (KEEP_PROPERTY or an error result) are still captured, and running jobs remain queryable throughgetJobInfos().Fixes #4126