The server's job queue (design notes §12): first in, first out, one job running at a time. Pure: the server keeps it in its state.
A job is any term with a client (the pid its output goes to). position/2 is the
number of jobs ahead of a client's: 0 while it runs.
Summary
Functions
Marks the running job done.
Drops the waiting jobs of client (it went away).
Whether nothing runs and nothing waits.
An empty queue.
Takes the next job to run when none is running: {job, queue} or :none.
The waiting jobs with their positions, in order (the first is 1 when one runs).
Adds job at the end; returns its position (jobs ahead of it, the running one included).
The number of waiting jobs.
Types
Functions
Marks the running job done.
Drops the waiting jobs of client (it went away).
Whether nothing runs and nothing waits.
@spec new() :: t()
An empty queue.
Takes the next job to run when none is running: {job, queue} or :none.
@spec positions(t()) :: [{job(), pos_integer()}]
The waiting jobs with their positions, in order (the first is 1 when one runs).
@spec push(t(), job()) :: {non_neg_integer(), t()}
Adds job at the end; returns its position (jobs ahead of it, the running one included).
@spec waiting(t()) :: non_neg_integer()
The number of waiting jobs.