endstone::Scheduler
Represents a scheduler that executes various tasks.
Functions:
Name | Description |
---|---|
cancelTask | |
cancelTasks | |
getPendingTasks | |
isQueued | |
isRunning | |
runTask | |
runTaskAsync | Returns a task that will be executed asynchronously on the next server tick. |
runTaskLater | |
runTaskLaterAsync | Returns a task that will be executed asynchronously after the specified number of server ticks. |
runTaskTimer | |
runTaskTimerAsync | Returns a task that will be executed repeatedly (and asynchronously) until cancelled, starting after the specified number of server ticks. |
cancelTask
void cancelTask(TaskId id)
Removes task from scheduler.
Parameters:
taskId
Id number of task to be removed
cancelTasks
void cancelTasks(Plugin &plugin)
Removes all tasks associated with a particular plugin from the scheduler.
Parameters:
plugin
Owner of tasks to be removed
getPendingTasks
std::vector<Task *> getPendingTasks()
Returns a vector of all pending tasks.
The ordering of the tasks is NOT related to their order of execution.
Returns:
Pending tasks
isQueued
bool isQueued(TaskId id)
Check if the task queued to be run later.
Parameters:
taskId
The task to check.
Returns:
If the task is queued to be run.
isRunning
bool isRunning(TaskId id)
Check if the task currently running.
Parameters:
taskId
The task to check.
Returns:
If the task is currently running.
runTask
std::shared_ptr<Task> runTask(Plugin &plugin, std::function<void()> task)
Returns a task that will be executed synchronously on the next server tick.
Parameters:
plugin
the reference to the plugin scheduling tasktask
the task to be run
Returns:
a Task that contains the id number (nullptr if task is empty)
runTaskAsync
std::shared_ptr<Task> runTaskAsync(Plugin &plugin, std::function<void()> task)
Returns a task that will be executed asynchronously on the next server tick.
Remark:
Asynchronous tasks should never access any Endstone API
Parameters:
plugin
the reference to the plugin scheduling tasktask
the task to be run
Returns:
a Task that contains the id number (nullptr if task is empty)
runTaskLater
std::shared_ptr<Task> runTaskLater(Plugin &plugin, std::function<void()> task,
std::uint64_t delay)
Returns a task that will be executed synchronously after the specified number of server ticks.
Parameters:
plugin
the reference to the plugin scheduling tasktask
the task to be rundelay
the ticks to wait before running the task
Returns:
a Task that contains the id number (nullptr if task is empty)
runTaskLaterAsync
std::shared_ptr<Task> runTaskLaterAsync(Plugin &plugin,
std::function<void()> task,
std::uint64_t delay)
Returns a task that will be executed asynchronously after the specified number of server ticks.
Remark:
Asynchronous tasks should never access any Endstone API
Parameters:
plugin
the reference to the plugin scheduling tasktask
the task to be rundelay
the ticks to wait before running the task
Returns:
a Task that contains the id number (nullptr if task is empty)
runTaskTimer
std::shared_ptr<Task> runTaskTimer(Plugin &plugin, std::function<void()> task,
std::uint64_t delay, std::uint64_t period)
Returns a task that will be executed repeatedly (and synchronously) until cancelled, starting after the specified number of server ticks.
Parameters:
plugin
the reference to the plugin scheduling tasktask
the task to be rundelay
the ticks to wait before running the taskperiod
the ticks to wait between runs
Returns:
a Task that contains the id number (nullptr if task is empty)
runTaskTimerAsync
std::shared_ptr<Task> runTaskTimerAsync(Plugin &plugin,
std::function<void()> task,
std::uint64_t delay,
std::uint64_t period)
Returns a task that will be executed repeatedly (and asynchronously) until cancelled, starting after the specified number of server ticks.
Remark:
Asynchronous tasks should never access any Endstone API
Parameters:
plugin
the reference to the plugin scheduling tasktask
the task to be rundelay
the ticks to wait before running the taskperiod
the ticks to wait between runs
Returns:
a Task that contains the id number (nullptr if task is empty)