CPN
Computational Process Networks
Public Member Functions | Private Attributes | List of all members
CPN::QueueReader Class Reference

Definition of the reader portion of the CPN queue class. More...

#include <QueueReader.h>

+ Collaboration diagram for CPN::QueueReader:

Public Member Functions

 QueueReader (QueueReleaser *n, shared_ptr< QueueBase > q)
 
 ~QueueReader ()
 
const void * GetRawDequeuePtr (unsigned thresh, unsigned chan=0)
 
void Dequeue (unsigned count)
 
bool RawDequeue (void *data, unsigned count, unsigned numChans, unsigned chanStride)
 
bool RawDequeue (void *data, unsigned count)
 
void Reset ()
 
bool Flushed () const
 
unsigned NumChannels () const
 
unsigned MaxThreshold () const
 
unsigned QueueLength () const
 
unsigned Count () const
 
bool Empty () const
 
const std::string & GetDatatype () const
 
unsigned ChannelStride () const
 
Key_t GetKey () const
 
void Release ()
 
void NotifyTerminate ()
 Called by the node. More...
 
shared_ptr< QueueBaseGetQueue ()
 

Private Attributes

QueueReleaserreleaser
 
shared_ptr< QueueBasequeue
 

Detailed Description

Definition of the reader portion of the CPN queue class.

Definition at line 37 of file QueueReader.h.

Constructor & Destructor Documentation

CPN::QueueReader::QueueReader ( QueueReleaser n,
shared_ptr< QueueBase q 
)

Definition at line 31 of file QueueReader.cc.

32  : releaser(qr), queue(q)
33  {
34  }
QueueReleaser * releaser
Definition: QueueReader.h:152
shared_ptr< QueueBase > queue
Definition: QueueReader.h:153
CPN::QueueReader::~QueueReader ( )

Definition at line 36 of file QueueReader.cc.

References queue.

36  {
37  queue->ShutdownReader();
38  }
shared_ptr< QueueBase > queue
Definition: QueueReader.h:153

Member Function Documentation

unsigned CPN::QueueReader::ChannelStride ( ) const
Returns
The current channel stride, the returned value is only guaranteed to be consistent when called between calls to GetRawDequeuePtr and Dequeue.

Definition at line 73 of file QueueReader.cc.

References queue.

73 { return queue->DequeueChannelStride(); }
shared_ptr< QueueBase > queue
Definition: QueueReader.h:153
unsigned CPN::QueueReader::Count ( ) const

An accessor method for the number of elements currently in the queue.

Warning
This function violates the rules of CPN.
Returns
the number of elements in the queue.

Definition at line 65 of file QueueReader.cc.

References queue.

65 { return queue->Count(); }
shared_ptr< QueueBase > queue
Definition: QueueReader.h:153
void CPN::QueueReader::Dequeue ( unsigned  count)

This function is used to remove elements from the queue. count elements will be removed from the queue when this function is called.

Parameters
countthe number of bytes to remove from the queue
Invariant
count <= thresh from GetRawDequeuePtr

Definition at line 44 of file QueueReader.cc.

References queue.

44 { queue->Dequeue(count); }
shared_ptr< QueueBase > queue
Definition: QueueReader.h:153
bool CPN::QueueReader::Empty ( ) const
Warning
This function violates the rules of CPN.
Returns
true if the queue is empty

Definition at line 67 of file QueueReader.cc.

References queue.

67 { return queue->Empty(); }
shared_ptr< QueueBase > queue
Definition: QueueReader.h:153
bool CPN::QueueReader::Flushed ( ) const

Definition at line 57 of file QueueReader.cc.

References queue.

57 { return queue->Flushed(); }
shared_ptr< QueueBase > queue
Definition: QueueReader.h:153
const std::string & CPN::QueueReader::GetDatatype ( ) const
Returns
the typename for this queue

Definition at line 69 of file QueueReader.cc.

References queue.

69  {
70  return queue->GetDatatype();
71  }
shared_ptr< QueueBase > queue
Definition: QueueReader.h:153
Key_t CPN::QueueReader::GetKey ( ) const
Returns
the key associated with this endpoint

Definition at line 75 of file QueueReader.cc.

References queue.

Referenced by Release().

75 { return queue->GetReaderKey(); }
shared_ptr< QueueBase > queue
Definition: QueueReader.h:153

+ Here is the caller graph for this function:

shared_ptr<QueueBase> CPN::QueueReader::GetQueue ( )
inline

Definition at line 150 of file QueueReader.h.

150 { return queue; }
shared_ptr< QueueBase > queue
Definition: QueueReader.h:153
const void * CPN::QueueReader::GetRawDequeuePtr ( unsigned  thresh,
unsigned  chan = 0 
)

Get a pointer to a buffer containing elements.

Note
access to the memory locations pointed to by the returned pointer after Dequeue has been called is undefined.
Parameters
threshthe number of bytes to get
chanthe channel to use
Returns
A void* to a block of memory thresh bytes long blocks until threshold bytes available 0 if the writer has disconnected and there is not enough data to fill the request.

Definition at line 40 of file QueueReader.cc.

References queue.

40  {
41  return queue->GetRawDequeuePtr(thresh, chan);
42  }
shared_ptr< QueueBase > queue
Definition: QueueReader.h:153
unsigned CPN::QueueReader::MaxThreshold ( ) const
Returns
the maximum threshold this queue supports.

Definition at line 61 of file QueueReader.cc.

References queue.

61 { return queue->MaxThreshold(); }
shared_ptr< QueueBase > queue
Definition: QueueReader.h:153
void CPN::QueueReader::NotifyTerminate ( )

Called by the node.

Definition at line 77 of file QueueReader.cc.

References queue.

77 { queue->NotifyTerminate(); }
shared_ptr< QueueBase > queue
Definition: QueueReader.h:153
unsigned CPN::QueueReader::NumChannels ( ) const
Returns
the number of channels supported by this queue.

Definition at line 59 of file QueueReader.cc.

References queue.

59 { return queue->NumChannels(); }
shared_ptr< QueueBase > queue
Definition: QueueReader.h:153
unsigned CPN::QueueReader::QueueLength ( ) const

Definition at line 63 of file QueueReader.cc.

References queue.

63 { return queue->QueueLength(); }
shared_ptr< QueueBase > queue
Definition: QueueReader.h:153
bool CPN::QueueReader::RawDequeue ( void *  data,
unsigned  count,
unsigned  numChans,
unsigned  chanStride 
)

Dequeue data from the queue directly into the memory pointed to by data. This function shall be equivalent to a call to GetRawDequeuePtr then a memcpy and then a call to Dequeue.

Parameters
datapoiner to memory to dequeue to
countthe number of bytes to copy into data
numChansthe number of channels to write to
chanStridethe distance in bytes between the beginning of the channels in data.
Returns
true on success or false if the writer has disconnected and there is not enough data to fill the request.

Definition at line 46 of file QueueReader.cc.

References queue.

47  {
48  return queue->RawDequeue(data, count, numChans, chanStride);
49  }
shared_ptr< QueueBase > queue
Definition: QueueReader.h:153
bool CPN::QueueReader::RawDequeue ( void *  data,
unsigned  count 
)

A version of RawDequeue to use when there is only 1 channel.

Parameters
datathe data to enqueue
countthe number of bytes to enqueue
Returns
true on success or false if the writer has disconnected and there is not enough data to fill the request.

Definition at line 51 of file QueueReader.cc.

References queue.

51  {
52  return queue->RawDequeue(data, count);
53  }
shared_ptr< QueueBase > queue
Definition: QueueReader.h:153
void CPN::QueueReader::Release ( )

Release the reader and reclame resources, all futher operations are invalid.

Definition at line 79 of file QueueReader.cc.

References GetKey(), queue, releaser, and CPN::QueueReleaser::ReleaseReader().

79  {
80  queue->ShutdownReader();
82  }
QueueReleaser * releaser
Definition: QueueReader.h:152
virtual void ReleaseReader(Key_t rkey)=0
Key_t GetKey() const
Definition: QueueReader.cc:75
shared_ptr< QueueBase > queue
Definition: QueueReader.h:153

+ Here is the call graph for this function:

void CPN::QueueReader::Reset ( )

Definition at line 55 of file QueueReader.cc.

References queue.

55 { queue->Reset(); }
shared_ptr< QueueBase > queue
Definition: QueueReader.h:153

Member Data Documentation

shared_ptr<QueueBase> CPN::QueueReader::queue
private
QueueReleaser* CPN::QueueReader::releaser
private

Definition at line 152 of file QueueReader.h.

Referenced by Release().


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