@ThreadSafe public abstract class ScheduledRunnable extends Object implements Runnable
Runnable
that provides access to the scheduling facilities after scheduledConstructor and Description |
---|
ScheduledRunnable() |
Modifier and Type | Method and Description |
---|---|
void |
afterAsyncRun()
Runs after this runnable has finished asynchronously
|
void |
afterSyncRun()
Runs after this runnable has been executed synchronously
|
ScheduledTask |
asScheduledTask()
The scheduled representation of the runnable
|
void |
beforeRun()
Guaranteed to be run before this Runnable on the main thread, even if this runnable is going to be run
asynchronously, useful for collecting resources to work on.
|
void |
cancel()
Cancels the task and removes from execution.
|
int |
id()
Used internally to refer to this runnable, probably shouldn't be used by plugins
|
long |
interval()
Gets how long between runs this is supposed to wait if it is a repeating task
|
void |
markSchedule(ScheduledTask task) |
void |
setInterval(long interval)
Sets how long this runnable should wait between executions if this is a repeating task
|
public ScheduledRunnable()
public void beforeRun()
This method is invoked synchronously relative to the Runnable.run()
method
public void afterAsyncRun()
This method does not require the code to be thread-safe
public void afterSyncRun()
public final void cancel()
ScheduledTask.cancel()
WARNING: This is a delegated function. DO NOT call this method before it is scheduled. A NullPointerException
will be thrown. This can be called when task() != null
.
public final long interval()
WARNING: This is a delegated function. DO NOT call this method before it is scheduled. A NullPointerException
will be thrown. This can be called when task() != null
.
public final void setInterval(long interval)
If this task is synchronous to the main thread, the change will be immediate, if it is not, the change may
take an iteration to take effect, however interval()
will reflect the changes
immediately
WARNING: This is a delegated function. DO NOT call this method before it is scheduled. A NullPointerException
will be thrown. This can be called when task() != null
.
public final int id()
public ScheduledTask asScheduledTask()
ScheduledTask
object held within the scheduling implementation@InternalUseOnly public void markSchedule(ScheduledTask task)
Copyright © 2016. All rights reserved.