Meta::MProc Class Reference
Graph-based chaining/signalling and light-weight concurrent processing.
More...
#include <MProc.h>
List of all members.
Public Types |
|
typedef MMap< int, mvar > | SignalMap |
|
typedef MVector< int > | IdVec |
Public Member Functions |
| | MProc () |
| virtual | ~MProc () |
| void | queue (MProcTask *task, MProc::SignalMap *signalMap=0, double priority=0, 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 IdVec & | outEdges () const |
| const IdVec & | inEdges () const |
| bool | isThreaded () const |
| void | setThreaded (bool flag) |
| bool | terminate (bool block=true) |
| bool | hasTerminated () const |
| void | reset () |
| MProc * | outEdge (int outId) |
| MProc * | inEdge (int inId) |
| const MProc * | outEdge (int outId) const |
| const MProc * | inEdge (int inId) const |
| int | inId (int outId) const |
| int | outId (int inId) const |
| const mvar & | edgeData (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
| virtual Meta::MProc::~MProc |
( |
|
) |
[virtual] |
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 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:
-
| data | Associate additional application-specific data with the edge created. |
| virtual int Meta::MProc::connect |
( |
MProc * |
mp, |
|
|
const mvar & |
data = undef | |
|
) |
| | [virtual] |
Connect as an output edge the MProc mp.
- Parameters:
-
| data | Associates additional application-specific data with the edge to be created. |
- Returns:
- The out id allocated for this edge.
| virtual void Meta::MProc::detach |
( |
|
) |
[virtual] |
| virtual void Meta::MProc::disconnect |
( |
|
) |
[virtual] |
| 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.
| const mvar& Meta::MProc::edgeData |
( |
int |
outId |
) |
const |
Get the edge data associated with an output edge.
| bool Meta::MProc::hasTerminated |
( |
|
) |
const |
Check the termination status of this MProc.
- Returns:
- true is this thread has terminated (and is now safe to delete).
| const MProc* Meta::MProc::inEdge |
( |
int |
inId |
) |
const |
- Returns:
- The MProc identified by input edge inId.
| MProc* Meta::MProc::inEdge |
( |
int |
inId |
) |
|
- 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.
| const MProc* Meta::MProc::outEdge |
( |
int |
outId |
) |
const |
- Returns:
- The MProc identified by output edge outId.
| MProc* Meta::MProc::outEdge |
( |
int |
outId |
) |
|
- 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.
Queue an MProc for execution.
- Parameters:
-
| task | The task that will run this MProc. |
| signalMap | A pointer to a signal map if any to run on. signalMap is consumed by this call -- it should not be deleted. |
| priorty | Relative run priority. The MProcTask runs higher priority values first. |
| time | For timed execution, or null for untimed. time is consumed by this call -- it should not be deleted. |
| void Meta::MProc::reset |
( |
|
) |
|
After having been terminated, this method must be called to reset the MProc so that it may be queued or signalled again.
| void Meta::MProc::run |
( |
SignalMap * |
signalMap |
) |
|
| 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::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, |
|
|
const mvar & |
v, |
|
|
double |
priority, |
|
|
bool |
persist = true, |
|
|
const mtime * |
time = 0 | |
|
) |
| | [virtual] |
Signal an output edge with signal value v.
- Parameters:
-
| persist | If persist is true, in the event of failure to activate, this signal will persist through subsequent activation attempts. |
| time | Pass non-null for a timed execution. |
| 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 |
) |
[virtual] |
Signal an output edge with signal value undef.
| 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().
| virtual void Meta::MProc::signalAll |
( |
const mvar & |
v |
) |
[virtual] |
Signal all output edges with value v.
| virtual void Meta::MProc::signalAll |
( |
|
) |
[virtual] |
Signal all output edges with value from edge data.
| 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:
-
| block | If 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: