Package com.yahoo.jrt
Class Task
java.lang.Object
com.yahoo.jrt.Task
A Task enables a Runnable to be scheduled for execution in the
transport thread some time in the future. Tasks are used internally
to handle RPC timeouts. Use the
TransportThread.createTask method to create a task associated with a
Transport object. Note that Task execution is designed to
be low-cost, so do not expect extreme accuracy. Also note that any
tasks that are pending execution when the owning Transport
object is shut down will never be run.-
Method Summary
Modifier and TypeMethodDescriptionbooleankill()Cancel the execution of this task and make sure it can never be scheduled for execution again.voidschedule(double seconds) Schedule this task for execution.voidSchedule this task for execution as soon as possible.booleanCancel the execution of this task.
-
Method Details
-
schedule
public void schedule(double seconds) Schedule this task for execution. A task may be scheduled multiple times, but may only have a single pending execution time. Re-scheduling a task that is not yet run will move the execution time. If the task has already been executed, scheduling works just like if the task was never run.- Parameters:
seconds- the number of seconds until the task should be executed- See Also:
-
scheduleNow
public void scheduleNow()Schedule this task for execution as soon as possible. This will result in the task being executed the next time the reactor loop inside the owningTransportobject checks for tasks to run. If you have something that is even more urgent, or something you need to be executed even if theTransportis shut down, use theTransportThread.perform(java.lang.Runnable)method instead.- See Also:
-
unschedule
public boolean unschedule()Cancel the execution of this task.- Returns:
- true if the task was scheduled and we managed to avoid execution
-
kill
public boolean kill()Cancel the execution of this task and make sure it can never be scheduled for execution again. After this method is invoked, invoking thescheduleandscheduleNowmethods will have no effect.- Returns:
- true if the task was scheduled and we managed to avoid execution
-