Module gen_component

Generic component framework.

Copyright © 2007-2016 Zuse Institute Berlin

Version: $Id$

Authors: Thorsten Schuett (schuett@zib.de), Florian Schintke (schintke@zib.de).

Description

Generic component framework. This component and its usage are described in more detail in the 'User and Developers Guide' which can be found in user-dev-guide/main.pdf and online at http://scalaris.zib.de.

Data Types

bp()

bp() = {bp, MsgTag :: comm:msg_tag(), bp_name()}
     | {bp_cond, Condition :: function(), bp_name()}
     | {bp_cond, {module(), atom(), pos_integer()}, bp_name()}

bp_msg()

bp_msg() = {'$gen_component', bp, breakpoint, step, pid()}
         | {'$gen_component', bp, breakpoint, cont}
         | {'$gen_component', bp, msg_in_bp_waiting, pid()}
         | {'$gen_component', bp, barrier}
         | {'$gen_component',
            bp,
            bp_set_cond,
            function(),
            bp_name(),
            pid() | none}
         | {'$gen_component',
            bp,
            bp_set,
            comm:msg_tag(),
            bp_name(),
            pid() | none}
         | {'$gen_component',
            bp,
            bp_del,
            bp_name(),
            pid() | none}

bp_name()

bp_name() = atom()

gc_state()

gc_state() = 
    {module(),
     handler(),
     [bp()],
     boolean(),
     [bp_msg()],
     boolean(),
     pid() | unknown,
     [comm:mypid()]}

handler()

handler() = fun((comm:message(), user_state()) -> user_state())

option()

option() = {pid_groups_join_as,
            pid_groups:groupname(),
            pid_groups:pidname()}
         | {pid_groups_join_as,
            pid_groups:groupname(),
            {short_lived, pid_groups:pidname()}}
         | {erlang_register, Name :: atom()}
         | {spawn_opts, [spawn_option()]}
         | {wait_for_init}

spawn_option()

spawn_option() = link
               | monitor
               | {priority, Level :: normal | high | max}
               | {fullsweep_after, Number :: non_neg_integer()}
               | {min_heap_size, Size :: non_neg_integer()}
               | {min_bin_vheap_size,
                  VSize :: non_neg_integer()}

user_state()

user_state() = term()

Function Index

bp_about_to_kill/1Brings the given gen_component into a state that is paused in preparation of a graceful shutdown of all children of a supervisor.
bp_barrier/1delay further breakpoint requests until a breakpoint actually occurs.
bp_cont/1
bp_del/2
bp_del_async/2
bp_set/3
bp_set_cond/3Module:Function(Message, State, Params) will be evaluated to decide whether a BP is reached.
bp_set_cond_async/3
bp_step/1
change_handler/2change the handler for handling messages.
demonitor/1
demonitor/2
get_component_state/1
get_component_state/2
get_state/1
get_state/2
is_gen_component/1
kill/1
monitor/1Sets an erlang monitor using erlang:monitor/2 in a gen_component process and stores info to support killing gen_components with trace_mpath/proto_sched.
post_op/2perform a post op, i.e.
runnable/1
sleep/2
start/4
start/5
start_link/4

Function Details

kill/1

kill(Pid :: pid() | port() | atom()) -> ok

sleep/2

sleep(Pid :: pid() | port() | atom(),
      TimeInMs :: integer() | infinity) ->
         ok

is_gen_component/1

is_gen_component(Pid :: pid()) -> boolean()

runnable/1

runnable(Pid :: pid()) -> boolean()

get_state/1

get_state(Pid :: pid()) -> user_state() | failed

get_state/2

get_state(Pid :: pid(), Timeout :: non_neg_integer()) ->
             user_state() | failed

get_component_state/1

get_component_state(Pid :: pid()) -> gc_state()

get_component_state/2

get_component_state(Pid :: pid(), Timeout :: non_neg_integer()) ->
                       gc_state() | failed

change_handler/2

change_handler(UState :: user_state(), Handler :: handler()) ->
                  {'$gen_component',
                   [{on_handler, Handler :: handler()}, ...],
                   user_state()}

change the handler for handling messages

post_op/2

post_op(Msg :: comm:message(), UState :: user_state()) ->
           {'$gen_component',
            [{post_op, comm:message()}, ...],
            user_state()}

perform a post op, i.e. handle a message directly after another

bp_set/3

bp_set(Pid :: pid(),
       MsgTag :: comm:msg_tag(),
       BPName :: bp_name()) ->
          ok

bp_set_cond/3

bp_set_cond(Pid :: pid(),
            Cond :: {module(), atom(), 2}
                  | fun((comm:message(), State :: any()) ->
                            boolean()),
            BPName :: bp_name()) ->
               ok

Module:Function(Message, State, Params) will be evaluated to decide whether a BP is reached. Params can be used as a payload.

bp_set_cond_async/3

bp_set_cond_async(Pid :: pid(),
                  Cond :: {module(), atom(), 2}
                        | fun((comm:message(), State :: any()) ->
                                  boolean()),
                  BPName :: bp_name()) ->
                     ok

bp_del/2

bp_del(Pid :: pid(), BPName :: bp_name()) -> ok

bp_del_async/2

bp_del_async(Pid :: pid(), BPName :: bp_name()) -> ok

bp_step/1

bp_step(Pid :: pid()) -> {module(), On :: atom(), comm:message()}

bp_cont/1

bp_cont(Pid :: pid()) -> ok

bp_barrier/1

bp_barrier(Pid :: pid()) -> ok

delay further breakpoint requests until a breakpoint actually occurs

bp_about_to_kill/1

bp_about_to_kill(Pid :: pid()) -> ok

Brings the given gen_component into a state that is paused in preparation of a graceful shutdown of all children of a supervisor. Note: A monitor is used to safe-guard the (synchronous) creation of the breakpoint in cases of another interfering shutdown process.

See also: sup:sup_terminate_childs/1.

monitor/1

monitor(Pid :: comm:erl_local_pid_plain()) -> reference()

Sets an erlang monitor using erlang:monitor/2 in a gen_component process and stores info to support killing gen_components with trace_mpath/proto_sched.

See also: bp_about_to_kill/1.

demonitor/1

demonitor(MonitorRef :: reference()) -> true

demonitor/2

demonitor(MonitorRef :: reference(), OptionList :: [flush | info]) ->
             boolean()

start_link/4

start_link(Module :: module(),
           Handler :: handler(),
           Args :: term(),
           Options :: [option()]) ->
              {ok, pid()}

start/4

start(Module :: module(),
      Handler :: handler(),
      Args :: term(),
      Options :: [option()]) ->
         {ok, pid()}

start/5

start(Module :: module(),
      DefaultHandler :: handler(),
      Args :: term(),
      Options :: [option()],
      Supervisor :: pid()) ->
         no_return() | ok


Generated by EDoc, Feb 29 2016, 16:15:43.