Class TmfUiRefreshHandler

java.lang.Object
org.eclipse.tracecompass.tmf.ui.TmfUiRefreshHandler

public class TmfUiRefreshHandler extends Object
This handler offers "coalescing" of UI updates. When displaying live experiments containing a high number of traces, every trace will want to regularly update views with their new available data. This can cause a high number of threads calling 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 Details

    • getInstance

      public static TmfUiRefreshHandler getInstance()
      Get the handler's instance
      Returns:
      The singleton instance
    • dispose

      public void dispose()
      Cancel all current requests and dispose the handler.
    • queueUpdate

      public void queueUpdate(Object source, Runnable task)
      Queue a UI update. Threads that want to benefit from "UI coalescing" should send their Runnable to this method, instead of Display.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 - The Runnable to execute in the UI thread.