org.openide.util
Class RequestProcessor.Task

java.lang.Object
  extended by org.openide.util.Task
      extended by org.openide.util.RequestProcessor.Task
All Implemented Interfaces:
java.lang.Runnable, Cancellable
Enclosing class:
RequestProcessor

public final class RequestProcessor.Task
extends Task
implements Cancellable

The task describing the request sent to the processor. Cancellable since 4.1.


Field Summary
 
Fields inherited from class org.openide.util.Task
EMPTY, run
 
Constructor Summary
RequestProcessor.Task(java.lang.Runnable run)
           
RequestProcessor.Task(java.lang.Runnable run, int priority)
           
 
Method Summary
 boolean cancel()
          Removes the task from the queue.
 int getDelay()
          Getter for amount of millis till this task is started.
 int getPriority()
          Current priority of the task.
 void run()
          Start the task.
 void schedule(int delay)
          (Re-)schedules a task to run in the future.
 void setPriority(int priority)
          Changes the priority the task will be performed with.
 java.lang.String toString()
           
 void waitFinished()
          This method is an implementation of the waitFinished method in the RequestProcessor.Task.
 boolean waitFinished(long timeout)
          Enhanced reimplementation of the Task.waitFinished(long) method.
 
Methods inherited from class org.openide.util.Task
addTaskListener, debug, isFinished, notifyFinished, notifyRunning, removeTaskListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RequestProcessor.Task

RequestProcessor.Task(java.lang.Runnable run)
Parameters:
run - runnable to start
delay - amount of millis to wait
priority - the priorty of the task

RequestProcessor.Task

RequestProcessor.Task(java.lang.Runnable run,
                      int priority)
Method Detail

run

public void run()
Description copied from class: Task
Start the task. When it finishes (even with an exception) it calls Task.notifyFinished(). Subclasses may override this method, but they then need to call Task.notifyFinished() explicitly.

Note that this call runs synchronously, but typically the creator of the task will call this method in a separate thread.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class Task

getDelay

public int getDelay()
Getter for amount of millis till this task is started.

Returns:
amount of millis

schedule

public void schedule(int delay)
(Re-)schedules a task to run in the future. If the task has not been run yet, it is postponed to the new time. If it has already run and finished, it is scheduled to be started again. If it is currently running, it is nevertheless left to finish, and also scheduled to run again.

Parameters:
delay - time in milliseconds to wait (starting from now)

cancel

public boolean cancel()
Removes the task from the queue.

Specified by:
cancel in interface Cancellable
Returns:
true if the task has been removed from the queue, false it the task has already been processed

getPriority

public int getPriority()
Current priority of the task.

Returns:
the priority level (see e.g. Thread.NORM_PRIORITY

setPriority

public void setPriority(int priority)
Changes the priority the task will be performed with.

Parameters:
priority - the priority level (see e.g. Thread.NORM_PRIORITY

waitFinished

public void waitFinished()
This method is an implementation of the waitFinished method in the RequestProcessor.Task. It check the current thread if it is request processor thread and in such case runs the task immediatelly to prevent deadlocks.

Overrides:
waitFinished in class Task

waitFinished

public boolean waitFinished(long timeout)
                     throws java.lang.InterruptedException
Enhanced reimplementation of the Task.waitFinished(long) method. The added semantic is that if one calls this method from another task of the same processor, and the task has not yet been executed, the method will immediatelly detect that and throw InterruptedException to signal that state.

Overrides:
waitFinished in class Task
Parameters:
timeout - the amount of time to wait
Returns:
true if the task was finished successfully during the timeout period, false otherwise
Throws:
java.lang.InterruptedException - if waiting has been interrupted or if the wait cannot succeed due to possible deadlock collision
Since:
5.0

toString

public java.lang.String toString()
Overrides:
toString in class Task