Package org.spongepowered.api.scheduler
Interface Scheduler
public interface Scheduler
Represents a scheduler for running
tasks
.-
Method Summary
Modifier and TypeMethodDescriptionexecutor
(org.spongepowered.plugin.PluginContainer plugin) Gets anexecutor
that can be used to schedule tasks through the standard Java concurrency interfaces.Retrieves a scheduled or running task by its unique ID.Returns a set ofTask
s that match the Regular Expression pattern.Submit aTask
to this scheduler and returns the task as aScheduledTask
.tasks()
Returns a set of all currently scheduled tasks.tasks
(org.spongepowered.plugin.PluginContainer plugin) Returns a set of all currently scheduled tasks owned by the given plugin.
-
Method Details
-
findTask
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
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
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
Set<ScheduledTask> tasks()Returns a set of all currently scheduled tasks.- Returns:
- A set of scheduled tasks
-
executor
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
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
- Parameters:
task
- The taskname
- The name- Returns:
- The scheduled task
-