Class SerialTaskQueue
A task is a Supplier<Mono<Void>>. The next task does not start
until the Mono returned by the previous task terminates.
Tasks run on the given scheduler.
Cancelling the Mono returned by submit(java.util.function.Supplier<reactor.core.publisher.Mono<java.lang.Void>>) before the task
starts means the task is skipped. Cancelling after the task starts has
no effect on the task; it still runs to completion before the next task starts.
A task must not wait for the completion of another task submitted to the same queue,
or it will deadlock. Attempting to do so fails with IllegalStateException.
If the scheduler rejects work (for example, because it was disposed), every task waiting in the queue fails with the scheduler's exception instead of waiting forever. A task already running is not affected.
Each task's Mono is subscribed with a Reactor Context that identifies this queue.
Code that must only run as part of a task can verify this with requireInTask().
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<Void> Returns a Mono that completes if it is part of a task running on this queue, or fails withIllegalStateExceptionotherwise.reactor.core.publisher.Mono<Void> Returns a Mono that, when subscribed, enqueues the task and completes (or fails) when the task's Mono terminates.
-
Constructor Details
-
SerialTaskQueue
public SerialTaskQueue(reactor.core.scheduler.Scheduler scheduler)
-
-
Method Details
-
submit
Returns a Mono that, when subscribed, enqueues the task and completes (or fails) when the task's Mono terminates. -
requireInTask
Returns a Mono that completes if it is part of a task running on this queue, or fails withIllegalStateExceptionotherwise.The check uses the Reactor Context, so it works regardless of which thread runs the task.
-