View Source shq (shq v0.1.1)

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

-type opts() :: opts_map() | opts_list().
Queue options, either a map or proplist.
-type opts_list() :: [{max, non_neg_integer() | infinity}].
-type opts_map() :: #{max => non_neg_integer() | infinity}.
-type 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.
-type 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

-spec 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.

-spec drain(ServerRef :: server_ref()) -> [Item :: term()].
Drain the queue from the front.
-spec drain_r(ServerRef :: server_ref()) -> [Item :: term()].
Drain the queue from the rear.
-spec 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
-spec 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.
-spec 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
-spec 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.
-spec 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.

-spec out(ServerRef :: server_ref()) -> {ok, Item :: term()} | empty.
Retrieve and remove an item from the front of a queue immediately.
-spec 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.
-spec 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
-spec 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.
-spec peek(ServerRef :: server_ref()) -> {ok, Item :: term()} | empty.
Retrieve an item from the front of a queue without removing it.
-spec peek_r(ServerRef :: server_ref()) -> {ok, Item :: term()} | empty.
Retrieve an item from the rear of a queue without removing it.
-spec size(ServerRef :: server_ref()) -> Size :: non_neg_integer().
Get the number of items currently in a queue.
-spec start(Opts :: opts()) -> {ok, pid()}.
Start an non-linked anonymous queue.
-spec start(ServerName :: server_name(), Opts :: opts()) ->
         {ok, pid()} | {error, Reason :: already_started}.
Start an non-linked named queue.
-spec start_link(Opts :: opts()) -> {ok, pid()}.
Start an linked anonymous queue.
Link to this function

start_link(ServerName, Opts)

View Source
-spec start_link(ServerName :: server_name(), Opts :: opts()) ->
              {ok, pid()} | {error, Reason :: already_started}.
Start an linked named queue.
-spec start_monitor(Opts :: opts()) -> {ok, {pid(), reference()}}.
Start an monitored anonymous queue.
Link to this function

start_monitor(ServerName, Opts)

View Source
-spec start_monitor(ServerName :: server_name(), Opts :: opts()) ->
                 {ok, {pid(), reference()}} | {error, Reason :: already_started}.
Start an monitored named queue.
-spec status(ServerRef :: server_ref()) -> open | closed.
Get the queue status, which is either open or closed.

See also: close/1, open/1.

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