Fast Erlang Pool
Fast Erlang Pool on NIF lock-free Queue using C++ the library: moodycamel::concurrentqueue
An industrial-strength lock-free queue for C++.
Features:
Sometimes you need a pool of workers when: one worker - one operation (for example, processing one connection to the server).
$ rebar3 compile
{ok, Ref} = fep:create_pool({fep_example, 1}), % Create a pool.
{ok, Pid} = supervisor:start_child(worker_sup, [Ref]),
% In worker.
% fep:push(PoolRef)
% They created workers, each worker put himself in the pool.
Pid = fep:pop(Ref). % We take the worker from the pool.
worker:run(Pid) % We call the worker.
% The worker after processing the job, puts himself in the pool.
% fep:push(PoolRef)
% kill worker
exit(Pid, normal).
% We can check if the worker is alive before giving:
empty = fep:pop_if_alive(Ref).
% Or if pool not empty and process is dead.
dead = fep:pop_if_alive(Ref).