bisphone / Toveri

A Minimal Process Ring Buffer for Erlang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Toveri

A minimal process ring buffer to supervise and rotate on processes. It’s like a process pool except that you don’t keep hold of a process when you fetch one from a buffer.

API

Make a sized ring buffer

toveri:new(RingBufName, Size) -> {ok, Pid} | {error, Reason}

RingBufName = atom()
Size = non_neg_integer()
Pid = pid()
Reason = {already_started, Pid}

Delete a supervised process ring buffer

toveri:delete(RingBufName) -> ok

RingBufName = atom()

Add a child (or a number of children) to a ring buffer

add_child(RingBufName, MFA) -> ok
add_child(RingBufName, MFA, Count) -> ok

RingBufName = atom()
MFA = mfa()
Count = non_neg_integer()

Get the size of a ring buffer

toveri:get_size(RingBufName) -> {ok, Size} | {error, Reason}

RingBufName = atom()
Size = non_neg_integer()
Reason = no_such_ring

Get a process from a ring buffer

toveri:get_pid(RingBufName) -> {ok, Pid} | {error, Reason}

RingBufName = atom()
Pid = pid()
Pos = non_neg_integer()
Reason = no_such_ring | {empty, Pos}

Get a process from a specific position of a ring buffer

toveri:get_pid(RingBufName, Pos) -> {ok, Pid} | {error, Reason}

RingBufName = atom()
Pid = pid()
Pos = non_neg_integer()
Reason = no_such_ring | {empty, Pos}

About

A Minimal Process Ring Buffer for Erlang

License:Other


Languages

Language:Erlang 98.1%Language:Makefile 1.9%