Class TmfUiRefreshHandler
Display.asyncExec(java.lang.Runnable)
repeatedly, which can really impede UI responsiveness.
Instead of calling Display.asyncExec(java.lang.Runnable) directly, threads that want to
queue updates to the UI can instead call
queueUpdate(java.lang.Object, java.lang.Runnable). If the handler is not currently
executing another update it will be scheduled immediately. Otherwise the
update will be queued.
The handler will only execute one update at a time. While it is busy, new requests received from a source that is already in the queue will replace the previous one (as we assume the latest UI update request is the most up-to-date and interesting one), preserving the previous request order. New requests received from other sources will be added to the end of the queue (keeping only the latest request from each source).
Once the current update is completed, the oldest request in the queue will be
sent to the UI thread via one single call to Display.syncExec(java.lang.Runnable).
- Author:
- Alexandre Montplaisir
-
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()Cancel all current requests and dispose the handler.static TmfUiRefreshHandlerGet the handler's instancevoidqueueUpdate(Object source, Runnable task) Queue a UI update.
-
Method Details
-
getInstance
Get the handler's instance- Returns:
- The singleton instance
-
dispose
public void dispose()Cancel all current requests and dispose the handler. -
queueUpdate
Queue a UI update. Threads that want to benefit from "UI coalescing" should send theirRunnableto this method, instead ofDisplay.asyncExec(Runnable).- Parameters:
source- The source sending the request. Typically callers should use "this". When multiple requests are queued before being executed, only the latest request per source is actually sent.task- TheRunnableto execute in the UI thread.
-