AndroMeta  2.0.0
Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends
Meta::MMLRoot Class Reference

An MML program has one root object which initially createsother entities and helps to coordinate the interractions between them. More...

#include <MMLRoot.h>

Inheritance diagram for Meta::MMLRoot:
Meta::MMLEntity Meta::MObject Meta::MProcessor Meta::MObjectBase

List of all members.

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)
MProcTasktask ()
virtual mvar endRun ()

Static Public Member Functions

static MMLRootptr (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_

Detailed Description

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*.


Constructor & Destructor Documentation

Constructor.

Parameters:
taskThe 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.


Member Function Documentation

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.

Parameters:
delayThe delivery delay applied after the entity receives the event.
blockif true, block until the message is successfully delivered.
Returns:
true on success.
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.

Returns:
A vector of peers in the running group.
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.

Parameters:
dynamicIf true perform a dynamic cast and ensure type is MMLRoot.
Returns:
Pointer to successfully casted root entity or null in case of failure.

Reimplemented from Meta::MMLEntity.

Explicitly reclaim memory from detached entities. Normally reclaim runs internally and periodically during run().

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.

Parameters:
beforetrue to halt before reaching the time as opposed to at the top of that time.

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.

Stop run cycle. To resume, call setInterval().

virtual void Meta::MMLRoot::store ( mvar v) const [virtual]

Store method.

Reimplemented from Meta::MMLEntity.

Returns:
The task associated with this MML program.
bool Meta::MMLRoot::unicast ( int  peerId,
const mvar evt,
const mvar delay = 0,
bool  block = false 
)

Send an event to the designated peer.

Parameters:
delayThe delivery delay applied after the entity receives the event.
blockif true, block until the message is successfully delivered.
Returns:
true on success.

Member Data Documentation

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.


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