AndroMeta  2.0.0
Public Types | Public Member Functions
Meta::MProc Class Reference

Graph-based chaining/signalling and light-weight concurrent processing. More...

#include <MProc.h>

Inheritance diagram for Meta::MProc:
Meta::MNetProc

List of all members.

Public Types

typedef MMap< int, mvarSignalMap
typedef MVector< int > IdVec

Public Member Functions

 MProc ()
virtual ~MProc ()
void queue (MProcTask *task, MProc::SignalMap *signalMap=0, double priority=0, bool activate=false, const mtime *time=0)
virtual bool activate (SignalMap &signalMap)
virtual mvar run (SignalMap &signalMap)
void run (SignalMap *signalMap)
virtual int connect (MProc *mp, const mvar &data=undef)
virtual void connect (int outId, int inId, MProc *mp, const mvar &data=undef)
virtual void disconnect (int outId)
virtual void disconnect ()
virtual void detach ()
virtual void signal (int outId)
virtual void signal (int outId, const mvar &v)
virtual void signal (int outId, const mvar &v, double priority, bool persist=true, const mtime *time=0)
virtual void signalAll ()
virtual void signalAll (const mvar &v)
virtual void signalAll (const mvar &v, double priority, bool persist=true, const mtime *time=0)
const IdVecoutEdges () const
const IdVecinEdges () const
bool isThreaded () const
void setThreaded (bool flag)
bool terminate (bool block=true)
bool hasTerminated () const
void reset ()
MProcoutEdge (int outId)
MProcinEdge (int inId)
const MProcoutEdge (int outId) const
const MProcinEdge (int inId) const
int inId (int outId) const
int outId (int inId) const
const mvaredgeData (int outId) const
void setEdgeData (int outId, const mvar &v)

Detailed Description

Graph-based chaining/signalling and light-weight concurrent processing.

MProc provides a base class for creating a graph-based system or "network" of light-weight concurrent processes. It provides a thread abstraction which is useful in a variety of situations, e.g: recurrent processes, processes which are made up of several stages whereby some of the stages trigger others which may run parallel. MProc's are connected to one another and signal each other with mvar's. Signalling results in an attempt to activate() the MProc, according to an application-specific criteria. When an MProc is activated it is queued in an MProcTask to be run.


Constructor & Destructor Documentation

Constructor.

virtual Meta::MProc::~MProc ( ) [virtual]

Destructor.


Member Function Documentation

virtual bool Meta::MProc::activate ( SignalMap signalMap) [virtual]

Application specific activation function which is called whenever an MProc is signalled. The default behavior is to activate upon receiving signals from all input edges.

Returns:
true if this MProc is to be activated.
virtual int Meta::MProc::connect ( MProc mp,
const mvar data = undef 
) [virtual]

Connect as an output edge the MProc mp.

Parameters:
dataAssociates additional application-specific data with the edge to be created.
Returns:
The out id allocated for this edge.
virtual void Meta::MProc::connect ( int  outId,
int  inId,
MProc mp,
const mvar data = undef 
) [virtual]

Connect as an output edge the MProc mp, specifying the outId on this MProc and inId on mp.

Parameters:
dataAssociate additional application-specific data with the edge created.
virtual void Meta::MProc::detach ( ) [virtual]

Sever all inputs edges.

virtual void Meta::MProc::disconnect ( int  outId) [virtual]

Sever an output edge referred to by outId.

Returns:
The input id associated with the edge disconnected.
virtual void Meta::MProc::disconnect ( ) [virtual]

Sever all output edges.

const mvar& Meta::MProc::edgeData ( int  outId) const

Get the edge data associated with an output edge.

Check the termination status of this MProc.

Returns:
true is this thread has terminated (and is now safe to delete).
MProc* Meta::MProc::inEdge ( int  inId)
Returns:
The MProc identified by input edge inId.
const MProc* Meta::MProc::inEdge ( int  inId) const
Returns:
The MProc identified by input edge inId.
const IdVec& Meta::MProc::inEdges ( ) const
Returns:
A vector containing the id's of all input edges.
int Meta::MProc::inId ( int  outId) const
Returns:
The input id associated with the connection on the specified output id.
bool Meta::MProc::isThreaded ( ) const
Returns:
true if this MProc may be threaded.
MProc* Meta::MProc::outEdge ( int  outId)
Returns:
The MProc identified by output edge outId.
const MProc* Meta::MProc::outEdge ( int  outId) const
Returns:
The MProc identified by output edge outId.
const IdVec& Meta::MProc::outEdges ( ) const
Returns:
A vector containing the id's of all output edges.
int Meta::MProc::outId ( int  inId) const
Returns:
The output id associated with the connection on the specified input id.
void Meta::MProc::queue ( MProcTask task,
MProc::SignalMap signalMap = 0,
double  priority = 0,
bool  activate = false,
const mtime time = 0 
)

Queue an MProc for execution.

Parameters:
taskThe task that will run this MProc.
signalMapA pointer to a signal map if any to run on. signalMap is consumed by this call -- it should not be deleted.
priortyRelative run priority. The MProcTask runs higher priority values first.
activatetrue if the mproc should be have its activate() function called first.
timeFor timed execution, or null for untimed. time is consumed by this call -- it should not be deleted.

After having been terminated, this method must be called to reset the MProc so that it may be queued or signalled again.

virtual mvar Meta::MProc::run ( SignalMap signalMap) [virtual]

Application specific run method. Default behavior is to simply return 0.

Reimplemented in Meta::MNetProc.

void Meta::MProc::run ( SignalMap signalMap)

Do not call directly.

void Meta::MProc::setEdgeData ( int  outId,
const mvar v 
)

Set the edge data associated with an output edge.

void Meta::MProc::setThreaded ( bool  flag)

Set whether this MProc may be threaded -- if flag is false, this MProc always runs on the main thread.

virtual void Meta::MProc::signal ( int  outId) [virtual]

Signal an output edge with signal value undef.

virtual void Meta::MProc::signal ( int  outId,
const mvar v 
) [virtual]

Signal an output edge with signal value v.

virtual void Meta::MProc::signal ( int  outId,
const mvar v,
double  priority,
bool  persist = true,
const mtime time = 0 
) [virtual]

Signal an output edge with signal value v.

Parameters:
persistIf persist is true, in the event of failure to activate, this signal will persist through subsequent activation attempts.
timePass non-null for a timed execution.
virtual void Meta::MProc::signalAll ( ) [virtual]

Signal all output edges with value from edge data.

virtual void Meta::MProc::signalAll ( const mvar v) [virtual]

Signal all output edges with value v.

virtual void Meta::MProc::signalAll ( const mvar v,
double  priority,
bool  persist = true,
const mtime time = 0 
) [virtual]

Signal all output edges with value v. Similar to signal().

bool Meta::MProc::terminate ( bool  block = true)

Cleanly terminate this MProc. Clean in the sense that it continues its run() method, but will not allowed to activate again.

Parameters:
blockIf false, the MProc is terminated asynchronously.
Returns:
true If the MProc has terminated (and is now safe to delete).

The documentation for this class was generated from the following file: