Package org.spongepowered.api.scheduler
Interface Scheduler
-
public interface Scheduler
Represents a scheduler for runningtasks
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description TaskExecutorService
executor(org.spongepowered.plugin.PluginContainer plugin)
Gets anexecutor
that can be used to schedule tasks through the standard Java concurrency interfaces.java.util.Optional<ScheduledTask>
findTask(java.util.UUID id)
Retrieves a scheduled or running task by its unique ID.java.util.Set<ScheduledTask>
findTasks(java.lang.String pattern)
Returns a set ofTask
s that match the Regular Expression pattern.ScheduledTask
submit(Task task)
Submit aTask
to this scheduler and returns the task as aScheduledTask
.ScheduledTask
submit(Task task, java.lang.String name)
java.util.Set<ScheduledTask>
tasks()
Returns a set of all currently scheduled tasks.java.util.Set<ScheduledTask>
tasks(org.spongepowered.plugin.PluginContainer plugin)
Returns a set of all currently scheduled tasks owned by the given plugin.
-
-
-
Method Detail
-
findTask
java.util.Optional<ScheduledTask> findTask(java.util.UUID id)
Retrieves a scheduled or running task by its unique ID.- Parameters:
id
- The id of the task- Returns:
- The scheduled or running task, or
Optional.empty()
-
findTasks
java.util.Set<ScheduledTask> findTasks(java.lang.String pattern)
Returns a set ofTask
s that match the Regular Expression pattern.- Parameters:
pattern
- The regular expression pattern applied to the name of tasks- Returns:
- A set of
Task
s that have names that match the pattern, the set will be empty if no names match
-
tasks
java.util.Set<ScheduledTask> tasks(org.spongepowered.plugin.PluginContainer plugin)
Returns a set of all currently scheduled tasks owned by the given plugin.- Parameters:
plugin
- The plugin that created the tasks- Returns:
- A set of scheduled tasks
-
tasks
java.util.Set<ScheduledTask> tasks()
Returns a set of all currently scheduled tasks.- Returns:
- A set of scheduled tasks
-
executor
TaskExecutorService executor(org.spongepowered.plugin.PluginContainer plugin)
Gets anexecutor
that can be used to schedule tasks through the standard Java concurrency interfaces.- Parameters:
plugin
- The plugin that will own the created tasks- Returns:
- An executor that can be used to execute tasks
-
submit
ScheduledTask submit(Task task)
Submit aTask
to this scheduler and returns the task as aScheduledTask
.The name of the task will be the form:
PLUGIN_ID "-" ( "A-" | "S-" ) SERIAL_ID
Examples of default Task names:
"FooPlugin-A-12"
"BarPlugin-S-4322"
No two active tasks will have the same serial ID for the same synchronisation type.
i.eAPlugin-A-15
andBPlugin-A-15
is not possible butBPlugin-S-15
is.- Parameters:
task
- The task- Returns:
- The scheduled task
-
submit
ScheduledTask submit(Task task, java.lang.String name)
- Parameters:
task
- The taskname
- The name- Returns:
- The scheduled task
-
-