Interface Task<Output>


public interface Task<Output>
  • Method Details

    • step

      TaskStatus<Output> step(Scheduler scheduler)
      Perform one step of the task, returning the next step of the task and the conditions under which to perform it.

      Clients must only call step() at most once, and must not invoke step() after release() has been invoked.

    • release

      default void release()
      Release any transient system resources allocated to this task.

      Any system resources held must be released by this method, so that garbage collection can take care of the rest. For instance, if this object makes use of an OS-level Thread, that thread must be explicitly released to avoid resource leaks

      This method shall not be called on this object after invoking #step(Scheduler); nor shall step(Scheduler) be called after this method.

    • duplicate

      default Task<Output> duplicate(Executor executor)
      Produce a copy of this Task that can be stepped independently from this Task

      Clients must not invoke duplicate() after step(Scheduler) or release() has been invoked.

      Parameters:
      executor - the executor to use for the new Task
      Returns:
      a copy of this Task that can be stepped independently from this Task
    • andThen

      default <Output> Task<Output> andThen(Task<Output> task2)
    • dropOutput

      default Task<Unit> dropOutput()
    • calling

      static <Output> Task<Unit> calling(Task<Output> task)
    • callingWithSpan

      static <Output> Task<Unit> callingWithSpan(Task<Output> task)
    • delaying

      static Task<Unit> delaying(Duration duration)
    • emitting

      static <EventType> Task<Unit> emitting(EventType eventType, Topic<EventType> topic)
    • spawning

      static Task<Unit> spawning(TaskFactory<?> taskFactory)
    • spawning

      static Task<Unit> spawning(Consumer<Scheduler> f)
    • spawningWithSpan

      static Task<Unit> spawningWithSpan(TaskFactory<?> taskFactory)
    • spawningWithSpan

      static Task<Unit> spawningWithSpan(Consumer<Scheduler> f)
    • spawning

      static <Any> Task<Unit> spawning(List<TaskFactory<Any>> tasks)
    • run

      static Task<Unit> run(Consumer<Scheduler> f)
      Parameters:
      f - Must not yield
      Returns:
    • evaluate

      static <Output> Task<Output> evaluate(Function<Scheduler,Output> f)
    • empty

      static Task<Unit> empty()
    • of

      static <Output> Task<Output> of(Function<Scheduler,TaskStatus<Output>> f)