Interface Scheduler


  • public interface Scheduler
    Represents a scheduler for running tasks.
    • Method Detail

      • findTask

        Optional<ScheduledTask> findTask​(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

        Set<ScheduledTask> findTasks​(String pattern)
        Returns a set of Tasks that match the Regular Expression pattern.
        Parameters:
        pattern - The regular expression pattern applied to the name of tasks
        Returns:
        A set of Tasks that have names that match the pattern, the set will be empty if no names match
      • tasks

        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

        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 an executor 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 a Task to this scheduler and returns the task as a ScheduledTask.

        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.e APlugin-A-15 and BPlugin-A-15 is not possible but BPlugin-S-15 is.

        Parameters:
        task - The task
        Returns:
        The scheduled task
      • submit

        ScheduledTask submit​(Task task,
                             String name)
        Submit a Task with a specified name to this scheduler and returns the task as a ScheduledTask.
        Parameters:
        task - The task
        name - The name
        Returns:
        The scheduled task