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

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

#include <QueueWriter.h>

+ Collaboration diagram for CPN::QueueWriter:

Public Member Functions

 QueueWriter (QueueReleaser *qr, shared_ptr< QueueBase >)
 
 ~QueueWriter ()
 
void * GetRawEnqueuePtr (unsigned thresh, unsigned chan=0)
 
void Enqueue (unsigned count)
 
void RawEnqueue (const void *data, unsigned count, unsigned numChans, unsigned chanStride)
 
void RawEnqueue (const void *data, unsigned count)
 
void Flush ()
 
bool Flushed () const
 
unsigned NumChannels () const
 
unsigned MaxThreshold () const
 
unsigned QueueLength () const
 
unsigned Freespace () const
 
bool Full () const
 
unsigned ChannelStride () const
 
const std::string & GetDatatype () 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 writer portion of the CPN queue class.

Definition at line 37 of file QueueWriter.h.

Constructor & Destructor Documentation

CPN::QueueWriter::QueueWriter ( QueueReleaser qr,
shared_ptr< QueueBase q 
)

Definition at line 31 of file QueueWriter.cc.

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

Definition at line 36 of file QueueWriter.cc.

References queue.

36  {
37  queue->ShutdownWriter();
38  }
shared_ptr< QueueBase > queue
Definition: QueueWriter.h:159

Member Function Documentation

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

Definition at line 67 of file QueueWriter.cc.

References queue.

67 { return queue->EnqueueChannelStride(); }
shared_ptr< QueueBase > queue
Definition: QueueWriter.h:159
void CPN::QueueWriter::Enqueue ( unsigned  count)

This function is used to release the buffer obtained with GetRawEnqueuePtr. The count specifies the number of entries that we want to be placed in the buffer.

Note
A call to this function without an accompanying call to GetRawEnqueuePtr is undefined.
Parameters
countthe number of bytes to be placed in the buffer
Invariant
count <= thresh from GetRawEnqueuePtr

Definition at line 42 of file QueueWriter.cc.

References queue.

42 { queue->Enqueue(count); }
shared_ptr< QueueBase > queue
Definition: QueueWriter.h:159
void CPN::QueueWriter::Flush ( )

Definition at line 53 of file QueueWriter.cc.

References queue.

53 { queue->Flush(); }
shared_ptr< QueueBase > queue
Definition: QueueWriter.h:159
bool CPN::QueueWriter::Flushed ( ) const

Definition at line 55 of file QueueWriter.cc.

References queue.

55 { return queue->Flushed(); }
shared_ptr< QueueBase > queue
Definition: QueueWriter.h:159
unsigned CPN::QueueWriter::Freespace ( ) const

Get the space available in elements.

Warning
This function violates the rules of CPN.
Returns
the number of bytes we can add to the queue without blocking.

Definition at line 63 of file QueueWriter.cc.

References queue.

63 { return queue->Freespace(); }
shared_ptr< QueueBase > queue
Definition: QueueWriter.h:159
bool CPN::QueueWriter::Full ( ) const

Test if the queue is currently full.

Warning
This function violates the rules of CPN.
Returns
true if the queue is full, false otherwise

Definition at line 65 of file QueueWriter.cc.

References queue.

65 { return queue->Full(); }
shared_ptr< QueueBase > queue
Definition: QueueWriter.h:159
const std::string & CPN::QueueWriter::GetDatatype ( ) const
Returns
the typename for this queue

Definition at line 69 of file QueueWriter.cc.

References queue.

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

Definition at line 71 of file QueueWriter.cc.

References queue.

Referenced by Release().

71 { return queue->GetWriterKey(); }
shared_ptr< QueueBase > queue
Definition: QueueWriter.h:159

+ Here is the caller graph for this function:

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

Definition at line 156 of file QueueWriter.h.

156 { return queue; }
shared_ptr< QueueBase > queue
Definition: QueueWriter.h:159
void * CPN::QueueWriter::GetRawEnqueuePtr ( unsigned  thresh,
unsigned  chan = 0 
)

Return a pointer to a buffer of memory that contains thresh entries that we can write into.

Note
A call to this function without an accompanying call to Enqueue is undefined.
An access to the memory locations defined by the return value is undefined after a call to Enqueue.
Parameters
threshthe number bytes we need in the returned buffer.
chanthe channel to use
Returns
void* to a block of memory at least thresh bytes long, blocks until thresh bytes available
Exceptions
BrokenQueueExceptionif the reader is released

Definition at line 39 of file QueueWriter.cc.

References queue.

39  {
40  return queue->GetRawEnqueuePtr(thresh, chan);
41  }
shared_ptr< QueueBase > queue
Definition: QueueWriter.h:159
unsigned CPN::QueueWriter::MaxThreshold ( ) const
Returns
the maximum threshold this queue supports.

Definition at line 59 of file QueueWriter.cc.

References queue.

59 { return queue->MaxThreshold(); }
shared_ptr< QueueBase > queue
Definition: QueueWriter.h:159
void CPN::QueueWriter::NotifyTerminate ( )

Called by the node.

Definition at line 73 of file QueueWriter.cc.

References queue.

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

Definition at line 57 of file QueueWriter.cc.

References queue.

57 { return queue->NumChannels(); }
shared_ptr< QueueBase > queue
Definition: QueueWriter.h:159
unsigned CPN::QueueWriter::QueueLength ( ) const

Definition at line 61 of file QueueWriter.cc.

References queue.

61 { return queue->QueueLength(); }
shared_ptr< QueueBase > queue
Definition: QueueWriter.h:159
void CPN::QueueWriter::RawEnqueue ( const void *  data,
unsigned  count,
unsigned  numChans,
unsigned  chanStride 
)

This function shall be equivalent to a call to GetRqwEnqueuePtr and a memcpy and then a call to Enqueue

The underlying implementatin may implement ether the GetRawEnqueuePtr and Enqueue or RawEnqueue and then implement the other in terms of the one implemented.

Parameters
datapointer to the memory to enqueue
countthe number of bytes to enqueue
numChansthe number of channels to write to
chanStridethe distance in bytes between the beginning of the channels in data.
Exceptions
BrokenQueueExceptionif the reader is released

Definition at line 44 of file QueueWriter.cc.

References queue.

45  {
46  queue->RawEnqueue(data, count, numChans, chanStride);
47  }
shared_ptr< QueueBase > queue
Definition: QueueWriter.h:159
void CPN::QueueWriter::RawEnqueue ( const void *  data,
unsigned  count 
)

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

Parameters
datapointer to the memory to enqueue
countthe number of bytes to enqueue
Exceptions
BrokenQueueExceptionif the reader is released

Definition at line 49 of file QueueWriter.cc.

References queue.

49  {
50  queue->RawEnqueue(data, count);
51  }
shared_ptr< QueueBase > queue
Definition: QueueWriter.h:159
void CPN::QueueWriter::Release ( )

Release this queue, will start releasing the resources used.

Definition at line 75 of file QueueWriter.cc.

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

75  {
76  queue->ShutdownWriter();
78  }
virtual void ReleaseWriter(Key_t wkey)=0
Key_t GetKey() const
Definition: QueueWriter.cc:71
shared_ptr< QueueBase > queue
Definition: QueueWriter.h:159
QueueReleaser * releaser
Definition: QueueWriter.h:158

+ Here is the call graph for this function:

Member Data Documentation

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

Definition at line 158 of file QueueWriter.h.

Referenced by Release().


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