Module gen_pnet

Callback function definitions and API for the gen_pnet behavior.

Copyright © 2016-2017 Jörgen Brandt

Version: 0.1.5

Behaviours: gen_server.

This module defines the gen_pnet behaviour.
Required callback functions: code_change/3, handle_call/3, handle_cast/2, handle_info/2, init/1, terminate/2, trigger/3, place_lst/0, trsn_lst/0, init_marking/2, preset/1, is_enabled/3, fire/3.

Authors: Jörgen Brandt (joergen.brandt@onlinehome.de).

See also: gen_pnet_iface, gen_pnet_struct.

Description

Callback function definitions and API for the gen_pnet behavior.

The callbacks defined for the gen_pnet behavior may be separated into a Petri net structure part and an actor interface part. Both behaviors are documented in the gen_pnet_struct and gen_pnet_iface modules respectively.

Data Types

name()

name() = atom() | {atom(), atom()} | {global, term()} | {via, atom(), term()} | pid()

prop()

prop() = atom() | {atom(), term()}

server_name()

server_name() = {local, atom()} | {global, atom()} | {via, atom(), term()}

start_link_result()

start_link_result() = {ok, pid()} | ignore | {error, term()}

Function Index

call/2Synchronously send the term Request to the net instance identified as Name and return the reply.
call/3Synchronously send the term Request to the net instance identified as Name and return the reply.
cast/2Asynchronously send the term Request to the net instance identified as Name.
get_ls/2Extracts the list of tokens on a given place from a given net state.
get_stats/1Extracts the stats field from a given net instance.
get_usr_info/1Extracts the user info field from a given net state.
ls/2Query the list of tokens on the place named Place in the net instance identified as Name.
marking/1Query the marking map of the net instance identified as Name associating to each place name the list of tokens that this place holds.
new/2Constructs an initial instance of a state record.
reply/2Sends a reply to a calling client process.
reset_stats/1Requests the net instance identified as Name to clear its stats.
start_link/3Starts an unregistered net instance.
start_link/4Starts a net instance registered as ServerName using the callback module IfaceMod as the interface module for this net instance.
stats/1Query the statistics gathered by the net instance identified as Name.
stop/1Requests the net instance identified as Name to stop.
usr_info/1Query the user info term from the net instance identified as Name.

Function Details

call/2

call(Name::name(), Request::term()) -> term()

Synchronously send the term Request to the net instance identified as Name and return the reply.

See also: call/3.

call/3

call(Name::name(), Request::term(), Timeout::non_neg_integer()) -> term()

Synchronously send the term Request to the net instance identified as Name and return the reply.

The timeout is explicitly set to Timeout`. The request is handled by the `handle_call/3 callback function of the interface module.

cast/2

cast(Name::name(), Request::term()) -> ok

Asynchronously send the term Request to the net instance identified as Name.

The request is handled by the handle_cast/2 callback function of the interface module. Note that the cast succeeds even if a non-existing process is addressed or the net instance is down.

get_ls/2

get_ls(Place::atom(), NetState::#net_state{}) -> [term()]

Extracts the list of tokens on a given place from a given net state.

Throws an error if the list does not exist.

get_stats/1

get_stats(NetState::#net_state{}) -> #stats{}

Extracts the stats field from a given net instance.

get_usr_info/1

get_usr_info(NetState::#net_state{}) -> term()

Extracts the user info field from a given net state.

ls/2

ls(Name, Place) -> {ok, [term()]} | {error, #bad_place{}}

Query the list of tokens on the place named Place in the net instance identified as Name.

Herein, Name can be a process id or a registered process name. The return value is either {ok, [_]}' if the place exists or a {error, #bad_place{}} tuple.

marking/1

marking(Name::name()) -> #{atom() => [term()]}

Query the marking map of the net instance identified as Name associating to each place name the list of tokens that this place holds.

Herein, Name can be a process id or a registered process name. The return value is the Petri net's marking map.

new/2

new(NetMod::atom(), UsrInfo::term()) -> #net_state{}

Constructs an initial instance of a state record.

Such a state record can be used to initialize a gen_pnet instance with start_link/1 or start_link/2.

See also: start_link/2, start_link/3.

reply/2

reply(Client::{pid(), term()}, Reply::term()) -> term()

Sends a reply to a calling client process.

This funciton is to be used when the reply to a caller has been deferred by returning {noreply, _, _} in handle_call/3.

See also: handle_call/3.

reset_stats/1

reset_stats(Name::name()) -> ok

Requests the net instance identified as Name to clear its stats.

start_link/3

start_link(IfaceMod, Args, Options) -> start_link_result()

Starts an unregistered net instance.

See also: start_link/4.

start_link/4

start_link(ServerName, IfaceMod, Args, Options) -> start_link_result()

Starts a net instance registered as ServerName using the callback module IfaceMod as the interface module for this net instance.

The Args argument is later handed to the init/1 callback. The ServerName argument can be {local, Name} | {global, Name} | {via, Module, ViaName}. Internally, the server name ServerName and option list Options are handed down to gen_server:start_link/4 as is.

See also: init/1.

stats/1

stats(Name::name()) -> #stats{}

Query the statistics gathered by the net instance identified as Name.

The throughput is given as a #stats{} record consisting of three #stat{} record instances characterizing the current, maximum, and minimum throughput of this net in transition firings per second.

stop/1

stop(Name::name()) -> ok

Requests the net instance identified as Name to stop.

usr_info/1

usr_info(Name::name()) -> term()

Query the user info term from the net instance identified as Name.


Generated by EDoc