GenLoop

This library is an adaptation of awesome Ulf Wiger's library :plain_fsm for Elixir. It reuses as :plain_fsm code as possible, but adds some features :

This is still a work in progress, notably the documentation must be completed.

Installation

The package can be installed by adding gen_loop and plain_fsm to your list of dependencies in mix.exs: We need to add plain_fsm because it is old on Hex repository, we use a more up-to-date version of the library (mainly to handle terminate/2 callback).

def deps do
  [
    {:gen_loop, "~> 0.1.0"},
    {:plain_fsm, github: "uwiger/plain_fsm", commit: "ae9eca8a8df8f61a32185b06882a55d60e62e904"},
  ]
end

Why ?

This library is a direct concurrent to GenServer and GenFsm : it provides selective receive and more freedom but makes it easier to shoot yourself in the foot.

More info in plain_fsm rationale.

How To ?

This section is still to be done, but basically :

Have a look at loop_example.ex.

Alternative

GenLoop is designed for communicating processes : servers, FSMs, etc. Have a look at the Task module if you just want to supervise autonomous processes.

GenLoop is not a replacement for GenServer : if your have only one loop in your module with a "catch all messages" clauses, you woud better use GenServer instead of GenLoop.