Pure scheduling transitions for one effect resource lane.
Summary
Functions
Returns true when a running or queued request matches.
Admits a request into a lane without performing effects.
Cancels all matching requests in this lane.
Cancels one request by id. Running work remains current until its candidate is finalized.
Releases the matching current request without promoting queued work.
Promotes the next queued request when a lane has no current request.
Builds an empty resource lane for a stable policy.
Finds the request id for a semantic operation id.
Types
@type action() :: {:start, MingaEditor.Effect.Request.t()} | {:stop, MingaEditor.Effect.Request.t()} | {:candidate, MingaEditor.Effect.Request.t(), {:canceled, cancel_reason()}} | {:terminal, MingaEditor.Effect.Request.t(), {:canceled, cancel_reason()}} | {:terminal, MingaEditor.Effect.Request.t(), {:stale, cancel_reason()}} | {:queue, [{MingaEditor.Effect.Request.t(), pos_integer(), non_neg_integer()}]}
@type admission() :: {:ok, MingaEditor.Effect.Request.id(), :running | :queued} | {:error, admission_error()}
@type admission_error() :: :policy_mismatch | :queue_full | :scheduler_full
@type cancel_reason() :: term()
@type t() :: %MingaEditor.EffectScheduler.Lane{ policy: MingaEditor.Effect.Policy.t(), queue: :queue.queue(MingaEditor.Effect.Request.t()), running: MingaEditor.Effect.Request.t() | nil }
Functions
@spec active?(t(), (MingaEditor.Effect.Request.t() -> boolean())) :: boolean()
Returns true when a running or queued request matches.
@spec admit(t() | nil, MingaEditor.Effect.Request.t(), boolean()) :: {admission(), t() | nil, [action()]}
Admits a request into a lane without performing effects.
@spec cancel_matching(t(), (MingaEditor.Effect.Request.t() -> boolean()), term()) :: {t(), [action()], boolean()}
Cancels all matching requests in this lane.
@spec cancel_request(t(), MingaEditor.Effect.Request.id()) :: {:ok, t(), [action()]} | :not_found
Cancels one request by id. Running work remains current until its candidate is finalized.
@spec finalize_current(t(), MingaEditor.Effect.Request.t()) :: {:empty, [action()]} | {t(), [action()]}
Releases the matching current request without promoting queued work.
Promotes the next queued request when a lane has no current request.
@spec new(MingaEditor.Effect.Policy.t()) :: t()
Builds an empty resource lane for a stable policy.
@spec request_id_for_operation(t(), MingaEditor.State.Operation.id()) :: MingaEditor.Effect.Request.id() | nil
Finds the request id for a semantic operation id.