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.
Callback function definitions and API for the gen_pnet
behavior.
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.
name() = atom() | {atom(), atom()} | {global, term()} | {via, atom(), term()} | pid()
prop() = atom() | {atom(), term()}
server_name() = {local, atom()} | {global, atom()} | {via, atom(), term()}
start_link_result() = {ok, pid()} | ignore | {error, term()}
call/2 | Synchronously send the term Request to the net instance identified as
Name and return the reply. |
call/3 | Synchronously send the term Request to the net instance identified as
Name and return the reply. |
cast/2 | Asynchronously send the term Request to the net instance identified as
Name . |
get_ls/2 | Extracts the list of tokens on a given place from a given net state. |
get_stats/1 | Extracts the stats field from a given net instance. |
get_usr_info/1 | Extracts the user info field from a given net state. |
ls/2 | Query the list of tokens on the place named Place in the net instance
identified as Name . |
marking/1 | Query the marking map of the net instance identified as Name
associating to each place name the list of tokens that this place holds. |
new/2 | Constructs an initial instance of a state record. |
reply/2 | Sends a reply to a calling client process. |
reset_stats/1 | Requests the net instance identified as Name to clear its stats. |
start_link/3 | Starts an unregistered net instance. |
start_link/4 | Starts a net instance registered as ServerName using the callback
module IfaceMod as the interface module for this net instance. |
stats/1 | Query the statistics gathered by the net instance identified as Name . |
stop/1 | Requests the net instance identified as Name to stop. |
usr_info/1 | Query the user info term from the net instance identified as Name . |
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(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.
Timeout`. The request is handled by
the `handle_call/3
callback function of the interface module.
cast(Name::name(), Request::term()) -> ok
Asynchronously send the term Request
to the net instance identified as
Name
.
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(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(NetState::#net_state{}) -> #stats{}
Extracts the stats field from a given net instance.
get_usr_info(NetState::#net_state{}) -> term()
Extracts the user info field from a given net state.
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
.
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(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.
Name
can be a process id or a registered process name. The
return value is the Petri net's marking map.
new(NetMod::atom(), UsrInfo::term()) -> #net_state{}
Constructs an initial instance of a state record.
Such a state record can be used to initialize agen_pnet
instance with
start_link/1
or start_link/2
.
See also: start_link/2, start_link/3.
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(Name::name()) -> ok
Requests the net instance identified as Name
to clear its stats.
start_link(IfaceMod, Args, Options) -> start_link_result()
Starts an unregistered net instance.
See also: 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.
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(Name::name()) -> #stats{}
Query the statistics gathered by the net instance identified as Name
.
#stats{}
record consisting of three
#stat{}
record instances characterizing the current, maximum, and
minimum throughput of this net in transition firings per second.
stop(Name::name()) -> ok
Requests the net instance identified as Name
to stop.
usr_info(Name::name()) -> term()
Query the user info term from the net instance identified as Name
.
Generated by EDoc