Class endstone::Scheduler¶
ClassList > endstone > Scheduler
Represents a scheduler that executes various tasks.
#include <endstone/scheduler/scheduler.h>
Public Functions¶
Type | Name |
---|---|
virtual void | cancelTask (TaskId id) = 0 |
virtual void | cancelTasks (Plugin & plugin) = 0 |
virtual std::vector< Task * > | getPendingTasks () = 0 |
virtual bool | isQueued (TaskId id) = 0 |
virtual bool | isRunning (TaskId id) = 0 |
virtual std::shared_ptr< Task > | runTask (Plugin & plugin, std::function< void()> task) = 0 |
virtual std::shared_ptr< Task > | runTaskAsync (Plugin & plugin, std::function< void()> task) = 0 Returns a task that will be executed asynchronously on the next server tick. |
virtual std::shared_ptr< Task > | runTaskLater (Plugin & plugin, std::function< void()> task, std::uint64_t delay) = 0 |
virtual std::shared_ptr< Task > | runTaskLaterAsync (Plugin & plugin, std::function< void()> task, std::uint64_t delay) = 0 Returns a task that will be executed asynchronously after the specified number of server ticks. |
virtual std::shared_ptr< Task > | runTaskTimer (Plugin & plugin, std::function< void()> task, std::uint64_t delay, std::uint64_t period) = 0 |
virtual std::shared_ptr< Task > | runTaskTimerAsync (Plugin & plugin, std::function< void()> task, std::uint64_t delay, std::uint64_t period) = 0 Returns a task that will be executed repeatedly (and asynchronously) until cancelled, starting after the specified number of server ticks. |
virtual | ~Scheduler () = default |
Public Functions Documentation¶
function cancelTask¶
Removes task from scheduler.
Parameters:
taskId
Id number of task to be removed
function cancelTasks¶
Removes all tasks associated with a particular plugin from the scheduler.
Parameters:
plugin
Owner of tasks to be removed
function getPendingTasks¶
Returns a vector of all pending tasks.
The ordering of the tasks is NOT related to their order of execution.
Returns:
Pending tasks
function isQueued¶
Check if the task queued to be run later.
Parameters:
taskId
The task to check.
Returns:
If the task is queued to be run.
function isRunning¶
Check if the task currently running.
Parameters:
taskId
The task to check.
Returns:
If the task is currently running.
function runTask¶
virtual std::shared_ptr< Task > endstone::Scheduler::runTask (
Plugin & plugin,
std::function< void()> task
) = 0
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)
function runTaskAsync¶
Returns a task that will be executed asynchronously on the next server tick.
virtual std::shared_ptr< Task > endstone::Scheduler::runTaskAsync (
Plugin & plugin,
std::function< void()> task
) = 0
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)
function runTaskLater¶
virtual std::shared_ptr< Task > endstone::Scheduler::runTaskLater (
Plugin & plugin,
std::function< void()> task,
std::uint64_t delay
) = 0
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)
function runTaskLaterAsync¶
Returns a task that will be executed asynchronously after the specified number of server ticks.
virtual std::shared_ptr< Task > endstone::Scheduler::runTaskLaterAsync (
Plugin & plugin,
std::function< void()> task,
std::uint64_t delay
) = 0
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)
function runTaskTimer¶
virtual std::shared_ptr< Task > endstone::Scheduler::runTaskTimer (
Plugin & plugin,
std::function< void()> task,
std::uint64_t delay,
std::uint64_t period
) = 0
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)
function runTaskTimerAsync¶
Returns a task that will be executed repeatedly (and asynchronously) until cancelled, starting after the specified number of server ticks.
virtual std::shared_ptr< Task > endstone::Scheduler::runTaskTimerAsync (
Plugin & plugin,
std::function< void()> task,
std::uint64_t delay,
std::uint64_t period
) = 0
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)
function ~Scheduler¶
The documentation for this class was generated from the following file include/endstone/scheduler/scheduler.h