|
AndroMeta
2.0.0
|
An MML program has one root object which initially createsother entities and helps to coordinate the interractions between them. More...
#include <MMLRoot.h>
Public Member Functions | |
| MMLRoot (MProcTask *task=0) | |
| MMLRoot (const mvar &v, RestoreOpt opt, MProcTask *task=0) | |
| virtual | ~MMLRoot () |
| virtual void | store (mvar &v) const |
| virtual mnode | process (mnode n, uint32_t flags=0) |
| void | setTime (const mvar &time) |
| void | setInterval (const mvar &dt) |
| void | setAutoEdges (bool flag) |
| void | stopRunCycle () |
| void | scheduleHalt (const mvar &time, bool before=false) |
| void | scheduleHalt () |
| virtual void | exit (int status=0) |
| bool | unicast (int peerId, const mvar &evt, const mvar &delay=0, bool block=false) |
| bool | broadcast (const mvar &evt, const mvar &delay=0, bool block=false) |
| void | barrier () |
| mvec | peers () |
| void | reclaim () |
| int | runTask () |
| int | runTask (const mtime &timeout) |
| MProcTask * | task () |
| virtual mvar | endRun () |
Static Public Member Functions | |
| static MMLRoot * | ptr (const mvar &v, bool dynamic=false) |
Static Public Attributes | |
| static const int | RunActive = 0 |
| static const int | RunHalted = 1 |
| static const int | RunEnded = 2 |
Friends | |
| class | MMLRoot_ |
| class | MMLEntity_ |
An MML program has one root object which initially createsother entities and helps to coordinate the interractions between them.
Programs that use MML must have exactly one root entity. The root entity typically initializes the program, creating entities which may then create other entities. It manages memory deallocation for entities that become detached, "reclaiming" the system resources used by them. The root object offers communication and syncrhonization methods for MML programs used in the the context of the AndroMeta peer-to-peer system and provides an interface for an MML program to perform optimization -- see examples/opt*.
| Meta::MMLRoot::MMLRoot | ( | MProcTask * | task = 0 | ) |
Constructor.
| task | The task used for concurrent processing. If null, then one is created and managed internally. |
| Meta::MMLRoot::MMLRoot | ( | const mvar & | v, |
| RestoreOpt | opt, | ||
| MProcTask * | task = 0 |
||
| ) |
Restore constructor.
| virtual Meta::MMLRoot::~MMLRoot | ( | ) | [virtual] |
Destructor.
| void Meta::MMLRoot::barrier | ( | ) |
Perform a barrier operation, syncrhonizing all peers in the running group. Blocks until all peers have entered the barrier.
| bool Meta::MMLRoot::broadcast | ( | const mvar & | evt, |
| const mvar & | delay = 0, |
||
| bool | block = false |
||
| ) |
Broadcast an event to all peers in the running group.
| delay | The delivery delay applied after the entity receives the event. |
| block | if true, block until the message is successfully delivered. |
| virtual mvar Meta::MMLRoot::endRun | ( | ) | [virtual] |
End run of root.
Reimplemented from Meta::MMLEntity.
| virtual void Meta::MMLRoot::exit | ( | int | status = 0 | ) | [virtual] |
Exit function to perform a clean shutdown.
| virtual mnode Meta::MMLRoot::process | ( | mnode | n, |
| uint32_t | flags = 0 |
||
| ) | [virtual] |
Process method.
Reimplemented from Meta::MMLEntity.
| static MMLRoot* Meta::MMLRoot::ptr | ( | const mvar & | v, |
| bool | dynamic = false |
||
| ) | [static] |
Convenience method to perform a cast on v to MMLRoot.
| dynamic | If true perform a dynamic cast and ensure type is MMLRoot. |
Reimplemented from Meta::MMLEntity.
| void Meta::MMLRoot::reclaim | ( | ) |
Explicitly reclaim memory from detached entities. Normally reclaim runs internally and periodically during run().
| int Meta::MMLRoot::runTask | ( | ) |
Blocking run on the task associated with the MML program.
| int Meta::MMLRoot::runTask | ( | const mtime & | timeout | ) |
Run the task associated with the MML program for a period of time.
| void Meta::MMLRoot::scheduleHalt | ( | const mvar & | time, |
| bool | before = false |
||
| ) |
Schedule a halt event at the specified time. When a halt event is reached, runTask() returns status RunHalted.
| before | true to halt before reaching the time as opposed to at the top of that time. |
| void Meta::MMLRoot::scheduleHalt | ( | ) |
Schedule a halt event after the next regular event is processed.
| void Meta::MMLRoot::setAutoEdges | ( | bool | flag | ) |
Set whether all edges are activating edges or activating edges are detected. Default is false.
| void Meta::MMLRoot::setInterval | ( | const mvar & | dt | ) |
Set the rate at which time is advanced each run cycle. The default interval is 1 time unit.
| void Meta::MMLRoot::setTime | ( | const mvar & | time | ) |
Set MML time. Do not call while an MML program is running.
| void Meta::MMLRoot::stopRunCycle | ( | ) |
Stop run cycle. To resume, call setInterval().
| virtual void Meta::MMLRoot::store | ( | mvar & | v | ) | const [virtual] |
Store method.
Reimplemented from Meta::MMLEntity.
| bool Meta::MMLRoot::unicast | ( | int | peerId, |
| const mvar & | evt, | ||
| const mvar & | delay = 0, |
||
| bool | block = false |
||
| ) |
Send an event to the designated peer.
| delay | The delivery delay applied after the entity receives the event. |
| block | if true, block until the message is successfully delivered. |
const int Meta::MMLRoot::RunActive = 0 [static] |
Run status codes returned by runTask(). RunActive means their is an active run in progress. RunHalted means a halt event has been reached. RunEnd means the end of time has been reached.
1.7.6.1