Interface GatewayProgressManager

All Superinterfaces:
ProgressManager

public interface GatewayProgressManager extends ProgressManager
The GatewayProgressManager is used to execute tasks on the gateway that might take a while. The tasks are initiated by a client (usually a designer), and updates on the task's state are fed back to the client progress system through the gateway's push mechanism.

The running tasks publish updates by retrieving the current progress listener for their thread through the function on this interface. This method is used due to the way that methods are invoked by the client on the gateway.

The easiest way to use this system is to write a GatewayFunc annotated function, and use the "asyncInvoke" flag of that annotation. That will cause the function to be passed through this system automatically.

  • Method Details

    • runAsyncTask

      String runAsyncTask(String sessionid, GatewayProgressRunnable task)
      Registers a task to run asynchronously. The provided task will be run in a different thread, who will have a threadlocal TaskProgressListener that can be updated. The registration returns a task uid that can be used to monitor the state.
      Parameters:
      sessionid - the client session that is interested in the progress of this task.
      task - the runnable to execute.
      Returns:
      the task uid
    • runAsyncTask

      String runAsyncTask(GatewayProgressRunnable task)
      Similar to runAsyncTask(String, GatewayProgressRunnable), but registers a task that doesn't exist under a user session.
    • cancelTask

      void cancelTask(String taskId)
      Sets the canceled flag of the specified task. The task will only be canceled if the executor watches the flag and exits.

      Right now unknown task ids are just ignored, but in the future we might want to throw an error. We may also want to provide some sort of feedback.

    • getProgressListenerForThread

      TaskProgressListener getProgressListenerForThread()
      Returns the TaskProgressListener registered for the calling thread. If no listener is registered, a "dummy" listener will be returned that will discard updates.
      Returns:
      a TaskProgressListener, guaranteed to not be null.
    • setProgressListenerForThread

      void setProgressListenerForThread(TaskProgressListener listener)
    • getState

      List<TaskProgressState> getState()
      Returns the current state of all running tasks.