Package swim.concurrent
Timers
A TimerFunction
represents a function to invoke at a scheduled
time. Scheduling a timer yields a TimerRef
, which can be used to
check the status of the timer, to reschedule it, and to cancel it. A Timer
represents a stateful TimerFunction
, with lifecycle callbacks,
and a TimerContext
that enables self-management.
Tasks
A TaskFunction
represents a function to invoke as a sequential
process in a concurrent environment. Registering a task yields a TaskRef
, which is used to cue the task for execution. A Task
represents a stateful TaskFunction
, with lifecycle callbacks, and a
TaskContext
that enables self-management. A Task
is like a
primitive actor that
lacks a builtin mailbox.
Cont
A Cont
represents the continuation of an asynchronous operation.
Cont
has factory functions to construct various Cont
inuation
combinators. Sync
implements a synchronous Cont
inuation that
continues the current thread of execution after an asynchronous operation
completes.
Calls
A Call
provides a handle used to eventually complete an
asynchronous operation by invoking a Cont
inuation. Although a
Cont
inuation can be completed directly, by invoking bind(T)
, or Cont.trap(Throwable)
, completeing a
Cont
inuation through a Call
abstracts over the execution
context in which the Cont
inuation runs. For example, a Call
returned by Stage.call(Cont)
invokes its bound Cont
inuation
in an asynchronous task, preventing unbounded stack growth from occurring
when chaining large numbers of Cont
inuations together.
Schedules
A Schedule
arranges for the on-time execution of timers. Clock
implements a Schedule
algorithm that efficiently scales to
large numbers of timers.
Stages
A Stage
concurrently executes sequential tasks. Theater
implements an execution Stage
backed by a ForkJoinPool
.
-
Interface Summary Interface Description Call<T> Handle used to eventually complete an asynchronous operation by invoking aCont
inuation.Cont<T> Continuation of an asynchronous operation.MainStage Stage
that can be started and stopped.Preemptive Function interface that callers can optionally invoke concurrently.PullContext<T> PullRequest<T> Schedule Timetable for executing timers at their scheduled times.ScheduleDef Marker interface for aSchedule
definition.Stage An execution context in which to schedule tasks, create continuation calls, and set timers.StageDef Marker interface for aStage
definition.Stay<T> Backpressure aware continuation.StayContext Source that can delay continuations.Task StatefulTaskFunction
to invoke as a sequential process on a concurrent executionStage
, with lifecycle callbacks, and aTaskContext
for self-management.TaskContext TaskFunction Function to invoke as a sequential process on a concurrent executionStage
.TaskRef External handle to aTaskFunction
bound to an executionStage
.Timer StatefulTimerFunction
to invoke at a scheduled time, with lifecycle callbacks, and aTimerContext
for self-management.TimerContext TimerFunction Function to invoke at a scheduled time.TimerRef External handle to aTimerFunction
bound to aSchedule
. -
Class Summary Class Description AbstractTask Skeletal implementation of a statefulTask
.AbstractTimer Skeletal implementation of a statefulTimer
.Clock Hashed wheel timerSchedule
.ClockDef ConcurrentTrancheQueue<T> PushRequest<T> SideStage Stage
wrapper that prevents its underlying stage from being started and stopped.StageClock Sync<T> ACont
inuation whose completion can be synchronously awaited.Theater Stage
that executes timers, tasks, and continuations on aForkJoinPool
.TheaterDef -
Exception Summary Exception Description ContException DropException Used to trap a continuation when aPullRequest
drops.ScheduleException Thrown when aSchedule
encounters an error.SyncException Thrown when awaiting aSync
continuation times out.TaskException Thrown when performing an invalid operation on aTaskFunction
.TimerException Thrown when performing an invalid operation on aTimerFunction
.