# Module proto_sched

- Description
- Data Types
- Function Index
- Function Details

Allow to centrally schedule all messages involved in a certain protocol execution and calculate the number of possible interleavings for convenience (so one can guess how often the protocol has to be run randomly to cover a good fraction of all possible interleavings).

Copyright © 2013-2015 Zuse Institute Berlin

Version: $Id:$

Behaviours: `gen_component`.

Authors: Florian Schintke (`schintke@zib.de`).

## Description

Allow to centrally schedule all messages involved in a certain protocol execution and calculate the number of possible interleavings for convenience (so one can guess how often the protocol has to be run randomly to cover a good fraction of all possible interleavings).

## Data Types

### anypid()

    anypid() = pid() | comm:mypid()

### callback_on_msg()

    callback_on_msg() =
        fun((Src :: comm:mypid(),
             Dest :: comm:mypid(),
             Msg :: comm:message()) ->
                ok)

### delay_queue_key()

    delay_queue_key() = {Dest :: anypid()}

### erlang_timestamp()

    erlang_timestamp() =
        {MegaSecs :: non_neg_integer(),
         Secs :: 0..999999,
         MicroSecs :: 0..999999}

### gc_mpath_msg()

    gc_mpath_msg() =
        {'$gen_component',
         trace_mpath,
         passed_state(),
         Src :: anypid(),
         Dest :: anypid(),
         comm:message()}

### info_event()

    info_event() =
        {log_info,
         Time :: '_',
         trace_id(),
         Source :: anypid(),
         Info :: comm:message()}

### logger()

    logger() = {proto_sched, comm:mypid()}

### msg_delay_queues()

    msg_delay_queues() = [delay_queue_key()]

### msg_queues()

    msg_queues() = [queue_key()]

### passed_state()

    passed_state() = {trace_id(), logger()}

### queue_key()

    queue_key() = {Src :: anypid(), Dest :: anypid()}

### send_event()

    send_event() =
        {log_send,
         Time :: '_',
         trace_id(),
         Source :: anypid(),
         Dest :: anypid(),
         comm:message(),
         local | global,
         comm:send_options()}

### state()

    state() = [{trace_id(), state_t()}]

### state_t()

    state_t() =
        #state{msg_queues = msg_queues(),
               msg_delay_queues = msg_delay_queues(),
               status =
                   new |
                   stopped |
                   running |
                   {delivered,
                    comm:mypid(),
                    reference(),
                    erlang_timestamp()},
               to_be_cleaned = false | {to_be_cleaned, pid()},
               passed_state = none | passed_state(),
               num_possible_executions = pos_integer(),
               num_delivered_msgs = non_neg_integer(),
               delivered_msgs =
                   [{Source :: anypid(),
                     Dest :: anypid(),
                     comm:message(),
                     local | global} |
                    {Source :: anypid(), info, comm:message()}],
               nums_chosen_from = [pos_integer()],
               callback_on_send = callback_on_msg(),
               callback_on_deliver = callback_on_msg(),
               thread_num = non_neg_integer(),
               threads_registered = non_neg_integer(),
               inform_on_end = pid() | none}

### trace_id()

    trace_id() = term()

## Function Index

cleanup/0 |
cleanup/1 |
clear_infection/0 |
epidemic_reply_msg/4 |
get_infos/0 |
get_infos/1 |
infected/0 |
info_shorten_messages/2 |
init/1 |
log_info/3 |
log_send/6 |
on/2 |
register_callback/2 |
register_callback/3 |
restore_infection/0 |
start/2 |
start_gen_component/5 |
start_link/1 |
thread_begin/0 |
thread_begin/1 |
thread_end/0 |
thread_end/1 |
thread_num/1 |
thread_num/2 |
thread_yield/0 |
wait_for_end/0 |
wait_for_end/1 |

## Function Details

### start_gen_component/5

    start_gen_component(Module :: module(),
                        Handler :: gen_component:handler(),
                        Args :: term(),
                        Options :: [gen_component:option()],
                        Self :: pid()) ->
                           no_return() | ok

### thread_num/1

    thread_num(N :: pos_integer()) -> ok

### thread_num/2

    thread_num(N :: pos_integer(), TraceId :: trace_id()) -> ok

### thread_begin/0

    thread_begin() -> ok

### thread_begin/1

    thread_begin(TraceId :: trace_id()) -> ok

### thread_yield/0

    thread_yield() -> ok

### thread_end/0

    thread_end() -> ok

### thread_end/1

    thread_end(TraceId :: trace_id()) -> ok

### wait_for_end/0

    wait_for_end() -> ok

### wait_for_end/1

    wait_for_end(TraceId :: trace_id()) -> ok

### start/2

    start(TraceId :: trace_id(), Logger :: logger()) -> ok

### register_callback/2

    register_callback(CallbackFun :: callback_on_msg(),
                      OnX :: on_send | on_deliver) ->
                         ok | failed

### register_callback/3

    register_callback(CallbackFun :: callback_on_msg(),
                      OnX :: on_send | on_deliver,
                      TraceId :: trace_id()) ->
                         ok | failed

### info_shorten_messages/2

    info_shorten_messages(Infos, CharsPerMsg :: pos_integer()) ->
                             Infos

-     Infos = [tuple()]

### get_infos/0

    get_infos() -> [tuple()]

### get_infos/1

    get_infos(TraceId :: trace_id()) -> [tuple()]

### infected/0

    infected() -> boolean()

### clear_infection/0

    clear_infection() -> ok

### restore_infection/0

    restore_infection() -> ok

### cleanup/0

    cleanup() -> ok

### cleanup/1

    cleanup(TraceId :: trace_id()) -> ok

### epidemic_reply_msg/4

    epidemic_reply_msg(PState :: passed_state(),
                       FromPid :: anypid(),
                       ToPid :: anypid(),
                       Msg :: comm:message()) ->
                          gc_mpath_msg()

### log_send/6

    log_send(PState :: passed_state(),
             FromPid :: anypid(),
             ToPid :: anypid(),
             Msg :: comm:message(),
             LocalOrGlobal :: local | global | local_after,
             SendOptions :: comm:send_options()) ->
                ok

### log_info/3

    log_info(PState :: passed_state(),
             FromPid :: anypid(),
             Info :: comm:message()) ->
                ok

### start_link/1

    start_link(ServiceGroup :: pid_groups:groupname()) -> {ok, pid()}

### init/1

    init(Arg :: any()) -> state()

### on/2

    on(ShepherdMsg :: send_event() | info_event() | comm:message(),
       State :: state()) ->
          state()

Generated by EDoc, Feb 29 2016, 16:12:21.