No Description

Adam Rutkowski d4097e4231 Bump version (1.0.2) 2 years ago
src d4097e4231 Bump version (1.0.2) 2 years ago
test f4f04d45cb Add start_supervised/3 2 years ago
.gitignore 4ff3dd2b63 Add .gitignore 4 years ago
.travis.yml f31d4fac0c Add travis.yml 4 years ago
LICENSE 73f036a077 Add license 2 years ago
Makefile 513e6106ea Add Makefile and rebar binary 4 years ago 875f7e39b6 Update README (fix typo) 4 years ago
rebar 513e6106ea Add Makefile and rebar binary 4 years ago
rebar.lock 43364934d9 Add lockfile (for rebar3) 2 years ago


Build Status

gen_cycle is a simple behaviour for recurring (on a regular basis) supervised tasks. Every task (cycle) is a separate process, calling arbitrary callback every N milliseconds. The callback results with cycle_op() type being a directive to either continue, continue hibernated, or stop. Additionally, a cycle can handle arbitrary Erlang messages. The result of message handling is expected to be cycle_op() as well.


$ rebar compile ct
==> gen_cycle (compile)
==> gen_cycle (ct)
Testing dev.gen_cycle: TEST COMPLETE, 5 ok, 0 failed of 5 test cases


A sample recurring task is implemented in tests. See here.


-type cycle_op() ::
    {continue, NewCycleData :: any()}
    | {continue_hibernated, NewCycleData :: any()}
    | {stop, Reason :: normal | any()}.


-callback init_cycle([InitArgs :: any()]) ->
    {ok, {Interval :: pos_integer(),
          InitCycleData :: any()}}
    | ignore.

-callback handle_cycle(CycleData :: any()) ->

-callback handle_info(Msg :: any(), CycleData :: any()) ->