Interface Scheduler


  • public interface Scheduler
    Represents a scheduler for running tasks.
    • 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 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

        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 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,
                             java.lang.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