shq (shq v0.0.1) View Source

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

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

in(ServerRef :: server_ref(), Item :: term()) -> ok | full | {error, Reason :: not_accepted}.
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 | {error, Reason :: not_accepted}.
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 | {error, Reason :: not_accepted}.
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 | {error, Reason :: not_accepted}.
Insert an item at the front of a queue, waiting for the given timeout if the queue is full.

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

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