Class LambdaTask

java.lang.Object
org.omegazero.common.event.task.AbstractTask
org.omegazero.common.event.task.LambdaTask
All Implemented Interfaces:
Comparable<Task>, Runnable, Task
Direct Known Subclasses:
TaskScheduler.TimerTask

public class LambdaTask extends AbstractTask
A Task based on a Consumer.
Since:
2.6
  • Constructor Details

    • LambdaTask

      public LambdaTask(Consumer<Object[]> handler, Object[] args)
      Creates a new LambdaTask.
      Parameters:
      handler - The task handler
      args - The arguments to pass to the task handler when this task is executed
      See Also:
    • LambdaTask

      public LambdaTask(Consumer<Object[]> handler, Object[] args, int priority)
      Creates a new LambdaTask.
      Parameters:
      handler - The task handler
      args - The arguments to pass to the task handler when this task is executed
      priority - The priority of this task
      See Also:
  • Method Details

    • destroy

      public void destroy()
      Removes the reference to the handler passed in the constructor.
      Since:
      2.9.2
    • execute

      protected void execute(Object[] args) throws Exception
      Description copied from class: AbstractTask
      Executes this task with the given arguments.
      Specified by:
      execute in class AbstractTask
      Parameters:
      args - The arguments to pass to the task handler
      Throws:
      Exception - If an error occurs