Collage  1.3.0
High-performance C++ library for developing object-oriented distributed applications.
co::Barrier Class Reference

A networked, versioned barrier. More...

#include <barrier.h>

+ Inheritance diagram for co::Barrier:
+ Collaboration diagram for co::Barrier:

Public Member Functions

CO_API Barrier (LocalNodePtr localNode, const uint128_t &masterNodeID, const uint32_t height=0)
 Construct and register a new distributed barrier. More...
 
CO_API Barrier (LocalNodePtr localNode, const ObjectVersion &barrier)
 Construct and join a distributed barrier. More...
 
virtual CO_API ~Barrier ()
 Destruct the barrier. More...
 
Data Access

After a change, the barrier has to be committed and synced to the same version on all nodes entering the barrier.

bool isGood () const
 
CO_API void setHeight (const uint32_t height)
 Set the number of participants in the barrier. More...
 
CO_API void increase ()
 Add one participant to the barrier. More...
 
CO_API uint32_t getHeight () const
 
Operations
CO_API bool enter (const uint32_t timeout=LB_TIMEOUT_INDEFINITE)
 Enter the barrier, blocks until the barrier has been reached. More...
 
- Public Member Functions inherited from co::Object
virtual CO_API ~Object ()
 Destruct the distributed object. More...
 
CO_API bool isAttached () const
 
CO_API LocalNodePtr getLocalNode ()
 
CO_API void setID (const uint128_t &identifier)
 Set the object's unique identifier. More...
 
CO_API const uint128_t & getID () const
 
CO_API uint32_t getInstanceID () const
 
CO_API bool isBuffered () const
 
CO_API bool isMaster () const
 
virtual uint64_t getMaxVersions () const
 Limit the number of queued versions on slave instances. More...
 
virtual CO_API uint32_t chooseCompressor () const
 Return the compressor to be used for data transmission. More...
 
virtual bool isDirty () const
 Return if this object needs a commit. More...
 
CO_API void push (const uint128_t &groupID, const uint128_t &objectType, const Nodes &nodes)
 Push the instance data of the object to the given nodes. More...
 
virtual CO_API uint128_t commit (const uint32_t incarnation=CO_COMMIT_NEXT)
 Commit a new version of this object. More...
 
CO_API void setAutoObsolete (const uint32_t count)
 Automatically obsolete old versions. More...
 
CO_API uint32_t getAutoObsolete () const
 
virtual CO_API uint128_t sync (const uint128_t &version=VERSION_HEAD)
 Sync to a given version. More...
 
CO_API uint128_t getHeadVersion () const
 
CO_API uint128_t getVersion () const
 
virtual CO_API void notifyNewHeadVersion (const uint128_t &version)
 Notification that a new head version was received by a slave object. More...
 
virtual void notifyNewVersion ()
 Notification that a new version was received by a master object. More...
 
CO_API ObjectOCommand send (NodePtr node, const uint32_t cmd, const uint32_t instanceID=CO_INSTANCE_ALL)
 Send a command with optional data to object instance(s) on another node. More...
 
virtual void notifyAttach ()
 Notify that this object will be registered or mapped. More...
 
virtual void notifyAttached ()
 Notify that this object has been registered or mapped. More...
 
virtual CO_API void notifyDetach ()
 Notify that this object will be deregistered or unmapped. More...
 
virtual void notifyDetached ()
 Notify that this object has been deregistered or unmapped. More...
 
uint32_t getMasterInstanceID () const
 
NodePtr getMasterNode ()
 
CO_API void removeSlave (NodePtr node, const uint32_t instanceID)
 
CO_API void removeSlaves (NodePtr node)
 
void setMasterNode (NodePtr node)
 
void addInstanceDatas (const ObjectDataIStreamDeque &, const uint128_t &)
 
void setupChangeManager (const Object::ChangeType type, const bool master, LocalNodePtr localNode, const uint32_t masterInstanceID)
 
virtual CO_API void detach ()
 
void transfer (Object *from)
 
void applyMapData (const uint128_t &version)
 
void sendInstanceData (Nodes &nodes)
 
- Public Member Functions inherited from co::Dispatcher
Dispatcheroperator= (const Dispatcher &)
 
template<typename T >
void registerCommand (const uint32_t command, const CommandFunc< T > &func, CommandQueue *queue)
 Register a command member function for a command. More...
 
virtual CO_API bool dispatchCommand (ICommand &command)
 Dispatch a command from the receiver thread to the registered queue. More...
 

Protected Member Functions

void attach (const uint128_t &id, const uint32_t instanceID) override
 
ChangeType getChangeType () const override
 
void getInstanceData (DataOStream &os) override
 Serialize all instance information of this distributed object. More...
 
void applyInstanceData (DataIStream &is) override
 Deserialize the instance data. More...
 
void pack (DataOStream &os) override
 Serialize the modifications since the last call to commit(). More...
 
void unpack (DataIStream &is) override
 Deserialize a change. More...
 
- Protected Member Functions inherited from co::Object
CO_API Object ()
 Construct a new distributed object. More...
 
Objectoperator= (const Object &)
 NOP assignment operator. More...
 
CO_API Object (const Object &)
 Copy construct a new, unattached object. More...
 
- Protected Member Functions inherited from co::Dispatcher
CO_API Dispatcher (const Dispatcher &from)
 
CO_API bool _cmdUnknown (ICommand &command)
 The default handler for handling commands. More...
 

Additional Inherited Members

- Public Types inherited from co::Object
enum  ChangeType {
  NONE, STATIC, INSTANCE, DELTA,
  UNBUFFERED
}
 Object change handling characteristics, see Programming Guide. More...
 
- Public Types inherited from co::Dispatcher
typedef CommandFunc< DispatcherFunc
 The signature of the base Dispatcher callback. More...
 

Detailed Description

A networked, versioned barrier.

On a given LocalNode only one instance of a given barrier can be mapped, i.e., multiple instances of the same barrier are currently not supported by the implementation. Not intended to be subclassed.

Definition at line 38 of file barrier.h.

Constructor & Destructor Documentation

CO_API co::Barrier::Barrier ( LocalNodePtr  localNode,
const uint128_t &  masterNodeID,
const uint32_t  height = 0 
)

Construct and register a new distributed barrier.

Barriers are versioned, distributed objects. This constructor creates and registers the barrier with its LocalNode. Other processes contributing to the barrier use the other constructor to create and map an instance to this master version.

The master node will maintain the barrier state. It has to be reachable from all other nodes participating in the barrier. If the master node identifier is not an UUID, the local node is used as the master.

Note that the node of the object master, i.e., the instance which is registered through this constructor, and the barrier's master node may be different. The barriers master node maintains the barrier state. The user of the barrier has to ensure that the given master node has at least one instance of the barrier.

Parameters
localNodethe local node to register the barrier with.
masterNodeIDthe master node identifier.
heightthe initial group size for the barrier.
See also
isGood()
Version
1.1.1
CO_API co::Barrier::Barrier ( LocalNodePtr  localNode,
const ObjectVersion barrier 
)

Construct and join a distributed barrier.

Parameters
localNodethe local node to map the barrier to
barrierthe identifier and version of the barrier
See also
isGood()
Version
1.1.1
virtual CO_API co::Barrier::~Barrier ( )
virtual

Destruct the barrier.

Version
1.0

Member Function Documentation

void co::Barrier::applyInstanceData ( DataIStream is)
overrideprotectedvirtual

Deserialize the instance data.

This method is called during object mapping to populate slave instances with the master object's data.

Parameters
isthe input stream.
Version
1.0

Implements co::Object.

CO_API bool co::Barrier::enter ( const uint32_t  timeout = LB_TIMEOUT_INDEFINITE)

Enter the barrier, blocks until the barrier has been reached.

The implementation currently assumes that the master node instance also enters the barrier.

Returns
true on success, false on timeout or error.
Version
1.0
ChangeType co::Barrier::getChangeType ( ) const
inlineoverrideprotectedvirtual
Returns
how the changes are to be handled.
Version
1.0

Reimplemented from co::Object.

Definition at line 120 of file barrier.h.

References co::Object::DELTA.

CO_API uint32_t co::Barrier::getHeight ( ) const
Returns
the number of participants.
Version
1.0
void co::Barrier::getInstanceData ( DataOStream os)
overrideprotectedvirtual

Serialize all instance information of this distributed object.

Parameters
osThe output stream.
Version
1.0

Implements co::Object.

CO_API void co::Barrier::increase ( )

Add one participant to the barrier.

Version
1.0
bool co::Barrier::isGood ( ) const
inline
Returns
true if the barrier was created successfully.
Version
1.1.1

Definition at line 90 of file barrier.h.

References co::Object::isAttached().

+ Here is the call graph for this function:

void co::Barrier::pack ( DataOStream os)
overrideprotectedvirtual

Serialize the modifications since the last call to commit().

No new version will be created if no data is written to the output stream.

Parameters
osthe output stream.
Version
1.0

Reimplemented from co::Object.

CO_API void co::Barrier::setHeight ( const uint32_t  height)

Set the number of participants in the barrier.

Version
1.0
void co::Barrier::unpack ( DataIStream is)
overrideprotectedvirtual

Deserialize a change.

Parameters
isthe input data stream.
Version
1.0

Reimplemented from co::Object.


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