Collage  1.2.1
High-performance C++ library for developing object-oriented distributed applications.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
co::QueueSlave Class Reference

The consumer end of a distributed queue. More...

#include <queueSlave.h>

+ Inheritance diagram for co::QueueSlave:
+ Collaboration diagram for co::QueueSlave:

Public Member Functions

CO_API QueueSlave (const uint32_t prefetchMark=LB_UNDEFINED_UINT32, const uint32_t prefetchAmount=LB_UNDEFINED_UINT32)
 Construct a new queue consumer. More...
 
virtual CO_API ~QueueSlave ()
 Destruct this queue consumer. More...
 
CO_API ObjectICommand pop (const uint32_t timeout=LB_TIMEOUT_INDEFINITE)
 Dequeue an item. 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...
 
virtual void pack (DataOStream &os)
 Serialize the modifications since the last call to commit(). More...
 
virtual void unpack (DataIStream &is)
 Deserialize a change. 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

ChangeType getChangeType () const override
 
void getInstanceData (co::DataOStream &) override
 Serialize all instance information of this distributed object. More...
 
void applyInstanceData (co::DataIStream &is) override
 Deserialize the instance data. 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

The consumer end of a distributed queue.

One or more instances of this class are mapped to the identifier of the QueueMaster registered on another node.

Definition at line 39 of file queueSlave.h.

Constructor & Destructor Documentation

CO_API co::QueueSlave::QueueSlave ( const uint32_t  prefetchMark = LB_UNDEFINED_UINT32,
const uint32_t  prefetchAmount = LB_UNDEFINED_UINT32 
)

Construct a new queue consumer.

The implementation will prefetch items from the queue master to cache them locally. The prefetchMark determines when new items are requested, and the prefetchAmount how many items are fetched. Prefetching items hides the network latency by pipelining the network communication with the processing, but introduces some imbalance between queue slaves.

Parameters
prefetchMarkthe low-water mark for prefetching, or LB_UNDEFINED_UINT32 to use the Global default.
prefetchAmountthe refill quantity when prefetching, or LB_UNDEFINED_UINT32 to use the Global default.
Version
1.0
virtual CO_API co::QueueSlave::~QueueSlave ( )
virtual

Destruct this queue consumer.

Version
1.0

Member Function Documentation

void co::QueueSlave::applyInstanceData ( co::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.

ChangeType co::QueueSlave::getChangeType ( ) const
inlineoverrideprotectedvirtual
Returns
how the changes are to be handled.
Version
1.0

Reimplemented from co::Object.

Definition at line 77 of file queueSlave.h.

References co::Object::STATIC.

void co::QueueSlave::getInstanceData ( co::DataOStream os)
inlineoverrideprotectedvirtual

Serialize all instance information of this distributed object.

Parameters
osThe output stream.
Version
1.0

Implements co::Object.

Definition at line 78 of file queueSlave.h.

CO_API ObjectICommand co::QueueSlave::pop ( const uint32_t  timeout = LB_TIMEOUT_INDEFINITE)

Dequeue an item.

The returned item can deserialize additional data using the DataIStream operators.

Parameters
timeoutAn optional timeout for the operation.
Returns
an item from the distributed queue, or an invalid item if the queue is empty or the operation timed out.
Version
1.0

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