Minga.Parser.ParseScheduler (Minga v0.1.0)

Copy Markdown View Source

Pure global admission state for editor-buffer parser synchronization.

The parser Port is single-threaded, so the manager admits one buffer snapshot or parse at a time. Repeated readiness signals coalesce by buffer PID.

Summary

Functions

Activates the next queued buffer when no work is active.

Returns whether the supplied buffer owns the active admission.

Associates a timeout token and timer with the active admission.

Queues a buffer once unless it is already active or queued.

Creates an empty scheduler.

Releases the matching active buffer.

Drops all active and queued admission state.

Returns whether a timeout belongs to the current active admission.

Returns the current admission timer reference.

Types

t()

@type t() :: %Minga.Parser.ParseScheduler{
  active: pid() | nil,
  queue: term(),
  queued: term(),
  timeout_ref: reference() | nil,
  timeout_token: term() | nil
}

Functions

activate_next(scheduler)

@spec activate_next(t()) :: {:ok, pid(), t()} | :busy | :empty

Activates the next queued buffer when no work is active.

active?(parse_scheduler, buffer_pid)

@spec active?(t(), pid()) :: boolean()

Returns whether the supplied buffer owns the active admission.

arm_timeout(scheduler, token, timer_ref)

@spec arm_timeout(t(), term(), reference()) :: t()

Associates a timeout token and timer with the active admission.

enqueue(scheduler, buffer_pid)

@spec enqueue(t(), pid()) :: t()

Queues a buffer once unless it is already active or queued.

new()

@spec new() :: t()

Creates an empty scheduler.

release(scheduler, buffer_pid)

@spec release(t(), pid()) :: t()

Releases the matching active buffer.

reset(parse_scheduler)

@spec reset(t()) :: t()

Drops all active and queued admission state.

timeout?(parse_scheduler, buffer_pid, token)

@spec timeout?(t(), pid(), term()) :: boolean()

Returns whether a timeout belongs to the current active admission.

timeout_ref(parse_scheduler)

@spec timeout_ref(t()) :: reference() | nil

Returns the current admission timer reference.