View Source shq (shq v0.1.0)

Shared inter-process queue.

Link to this section Summary

Types

Queue options, either a map or proplist.
See gen_server:start/3,4, gen_server:start_link/3,4, gen_server:start_monitor/3,4.
See gen_server:call/3,4, gen_server:cast/2.

Functions

Closes an open queue in order to reject subsequent and waiting inserts. A closed queue can be reopened with a call to open/1.

See also: in/2, in/3, in_r/2, in_r/3, open/1, status/1.

Drain the queue from the front.
Drain the queue from the rear.
Insert an item at the rear of a queue immediately.
Insert an item at the rear of a queue, waiting for the given timeout if the queue is full.
Insert an item at the front of a queue immediately.
Insert an item at the front of a queue, waiting for the given timeout if the queue is full.
Opens a closed queue to accept subsequent inserts.

See also: close/1, in/2, in/3, in_r/2, in_r/3, status/1.

Retrieve and remove an item from the front of a queue immediately.
Retrieve and remove an item from the front of a queue, waiting for the given timeout if the queue is empty.
Retrieve and remove an item from the rear of a queue immediately.
Retrieve and remove an item from the rear of a queue, waiting for the given timeout if the queue is empty.
Retrieve an item from the front of a queue without removing it.
Retrieve an item from the rear of a queue without removing it.
Get the number of items currently in a queue.
Start an non-linked anonymous queue.
Start an non-linked named queue.
Start an linked anonymous queue.
Start an linked named queue.
Start an monitored anonymous queue.
Start an monitored named queue.
Get the queue status, which is either open or closed.

See also: close/1, open/1.

Stop a queue. All remaining items will be discarded.

Link to this section Types

Specs

opts() :: opts_map() | opts_list().
Queue options, either a map or proplist.

Specs

opts_list() :: [{max, non_neg_integer() | infinity}].

Specs

opts_map() :: #{max => non_neg_integer() | infinity}.

Specs

server_name() ::
    {local, Name :: atom()} |
    {global, GlobalName :: term()} |
    {via, Via :: module(), ViaName :: term()}.
See gen_server:start/3,4, gen_server:start_link/3,4, gen_server:start_monitor/3,4.

Specs

server_ref() ::
    pid() |
    (Name :: atom()) |
    {Name :: atom(), Node :: node()} |
    {global, GlobalName :: term()} |
    {via, Via :: module(), ViaName :: term()}.
See gen_server:call/3,4, gen_server:cast/2.

Link to this section Functions

Specs

close(ServerRef :: server_ref()) -> ok.
Closes an open queue in order to reject subsequent and waiting inserts. A closed queue can be reopened with a call to open/1.

See also: in/2, in/3, in_r/2, in_r/3, open/1, status/1.

Specs

drain(ServerRef :: server_ref()) -> [Item :: term()].
Drain the queue from the front.

Specs

drain_r(ServerRef :: server_ref()) -> [Item :: term()].
Drain the queue from the rear.

Specs

in(ServerRef :: server_ref(), Item :: term()) -> ok | full | closed.
Insert an item at the rear of a queue immediately.
Link to this function

in(ServerRef, Item, Timeout)

View Source

Specs

in(ServerRef :: server_ref(), Item :: term(), Timeout :: timeout()) -> ok | full | closed.
Insert an item at the rear of a queue, waiting for the given timeout if the queue is full.

Specs

in_r(ServerRef :: server_ref(), Item :: term()) -> ok | full | closed.
Insert an item at the front of a queue immediately.
Link to this function

in_r(ServerRef, Item, Timeout)

View Source

Specs

in_r(ServerRef :: server_ref(), Item :: term(), Timeout :: timeout()) -> ok | full | closed.
Insert an item at the front of a queue, waiting for the given timeout if the queue is full.

Specs

open(ServerRef :: server_ref()) -> ok.
Opens a closed queue to accept subsequent inserts.

See also: close/1, in/2, in/3, in_r/2, in_r/3, status/1.

Specs

out(ServerRef :: server_ref()) -> {ok, Item :: term()} | empty.
Retrieve and remove an item from the front of a queue immediately.

Specs

out(ServerRef :: server_ref(), Timeout :: timeout()) -> {ok, Item :: term()} | empty.
Retrieve and remove an item from the front of a queue, waiting for the given timeout if the queue is empty.

Specs

out_r(ServerRef :: server_ref()) -> {ok, Item :: term()} | empty.
Retrieve and remove an item from the rear of a queue immediately.
Link to this function

out_r(ServerRef, Timeout)

View Source

Specs

out_r(ServerRef :: server_ref(), Timeout :: timeout()) -> {ok, Item :: term()} | empty.
Retrieve and remove an item from the rear of a queue, waiting for the given timeout if the queue is empty.

Specs

peek(ServerRef :: server_ref()) -> {ok, Item :: term()} | empty.
Retrieve an item from the front of a queue without removing it.

Specs

peek_r(ServerRef :: server_ref()) -> {ok, Item :: term()} | empty.
Retrieve an item from the rear of a queue without removing it.

Specs

size(ServerRef :: server_ref()) -> Size :: non_neg_integer().
Get the number of items currently in a queue.

Specs

start(Opts :: opts()) -> {ok, pid()}.
Start an non-linked anonymous queue.

Specs

start(ServerName :: server_name(), Opts :: opts()) ->
         {ok, pid()} | {error, Reason :: already_started}.
Start an non-linked named queue.

Specs

start_link(Opts :: opts()) -> {ok, pid()}.
Start an linked anonymous queue.
Link to this function

start_link(ServerName, Opts)

View Source

Specs

start_link(ServerName :: server_name(), Opts :: opts()) ->
              {ok, pid()} | {error, Reason :: already_started}.
Start an linked named queue.

Specs

start_monitor(Opts :: opts()) -> {ok, {pid(), reference()}}.
Start an monitored anonymous queue.
Link to this function

start_monitor(ServerName, Opts)

View Source

Specs

start_monitor(ServerName :: server_name(), Opts :: opts()) ->
                 {ok, {pid(), reference()}} | {error, Reason :: already_started}.
Start an monitored named queue.

Specs

status(ServerRef :: server_ref()) -> open | closed.
Get the queue status, which is either open or closed.

See also: close/1, open/1.

Specs

stop(ServerRef :: server_ref()) -> ok.
Stop a queue. All remaining items will be discarded.