All Packages  Class Hierarchy  This Package  Previous  Next  Index

Interface calypso.util.tasc.SHandle

public interface SHandle
An interface for scheduling handles. Scheduling handles are classes that are scheduled by schedulers. The tasks are not directly scheduled. Instead, they are given or they obtain a handle, whose schedule() method causes the corresponding task (or the handle) to be scheduled.

The main idea of the scheduling handles is that the same handle can be used to schedule the task multiple times, and that the same task can be scheduled by multiple schedulers by obtaining multiple handles for the task. Also, handles may implement fairly complicated scheduler-specific functionality that is hidden from tasks. See the concrete handle classes for examples.

Requirement 1: An already scheduled handle cannot be rescheduled before it has been either executed or cancelled. This means that at a certain moment, only one reference to a handle can be in at most one scheduling queue.

Requirement 2: Schedulers must make sure that the IsScheduled() method of the handle returns false before the run() method of the associated task is called, so that the task can reschedule the handle.

Author:
Petteri Koponen
See Also:
Scheduler, Task

Method Index

 o cancel()
Remove the handle from the scheduler.
 o isScheduled()
Is the handle scheduled? If this method returns false, it is safe to reschedule the handle.
 o schedule()
Schedule the handle.

Methods

 o isScheduled
 public abstract boolean isScheduled()
Is the handle scheduled? If this method returns false, it is safe to reschedule the handle. Schedulers must make sure that this returns false before the corresponding task is executed, so that the task can reschedule the handle if it wants to.

Returns:
true, if the handle is scheduled.
 o schedule
 public abstract void schedule()
Schedule the handle. The behavior in case the handle is already scheduled is implementation-dependent.

 o cancel
 public abstract int cancel()
Remove the handle from the scheduler. The schedule() method guarantees that there could be only one reference to the handle in the scheduler, which makes the implementation of this method more efficient (only one reference needs to be found and removed instead of all references).

Returns:
The number of references removed (always either 0 or 1).

All Packages  Class Hierarchy  This Package  Previous  Next  Index