#include <qchannel.h>
Inheritance diagram for PQueueChannel:
Public Member Functions | |
Construction | |
PQueueChannel (PINDEX queueSize=0) | |
Create a new queue channel with the specified maximum size. | |
~PQueueChannel () | |
Delete queue and release memory used. | |
Overrides from class PChannel | |
virtual PBoolean | Read (void *buf, PINDEX len) |
Low level read from the file channel. | |
virtual PBoolean | Write (const void *buf, PINDEX len) |
Low level write to the file channel. | |
virtual PBoolean | Close () |
Close the file channel. | |
Queue manipulation functions | |
virtual PBoolean | Open (PINDEX queueSize) |
Open a queue, allocating the queueSize bytes. | |
PINDEX | GetSize () const |
Get the queue size. | |
PINDEX | GetLength () const |
Get the current queue length. | |
Protected Attributes | |
PMutex | mutex |
BYTE * | queueBuffer |
PINDEX | queueSize |
PINDEX | queueLength |
PINDEX | enqueuePos |
PINDEX | dequeuePos |
PSyncPoint | unempty |
PSyncPoint | unfull |
This implements a simple memory based First In First Out queue. Data written to an instance of the class may be read from the same instance at some later time.
The queue will block the read for the Read Timeout if the queue is empty. Similarly a write will be clocked for Write Timeout if the queue is full.
If there is any data to be read then it returns immediately with those bytes, so you must check the GetLastReadCount() to determine the actual number of bytes read and not rely on the count being passed into the read function.
PQueueChannel::PQueueChannel | ( | PINDEX | queueSize = 0 |
) |
Create a new queue channel with the specified maximum size.
queueSize | Queue size |
PQueueChannel::~PQueueChannel | ( | ) |
Delete queue and release memory used.
virtual PBoolean PQueueChannel::Close | ( | ) | [virtual] |
PINDEX PQueueChannel::GetLength | ( | ) | const [inline] |
Get the current queue length.
PINDEX PQueueChannel::GetSize | ( | ) | const [inline] |
Get the queue size.
virtual PBoolean PQueueChannel::Open | ( | PINDEX | queueSize | ) | [virtual] |
Open a queue, allocating the queueSize bytes.
queueSize | Queue size |
virtual PBoolean PQueueChannel::Read | ( | void * | buf, | |
PINDEX | len | |||
) | [virtual] |
Low level read from the file channel.
The read timeout is ignored for file I/O. The GetLastReadCount() function returns the actual number of bytes read.
The GetErrorCode() function should be consulted after Read() returns false to determine what caused the failure.
buf | Pointer to a block of memory to receive the read bytes. |
len | Maximum number of bytes to read into the buffer. |
Reimplemented from PChannel.
virtual PBoolean PQueueChannel::Write | ( | const void * | buf, | |
PINDEX | len | |||
) | [virtual] |
Low level write to the file channel.
The write timeout is ignored for file I/O. The GetLastWriteCount() function returns the actual number of bytes written.
The GetErrorCode() function should be consulted after Write() returns false to determine what caused the failure.
buf | Pointer to a block of memory to write. |
len | Number of bytes to write. |
Reimplemented from PChannel.
PINDEX PQueueChannel::dequeuePos [protected] |
PINDEX PQueueChannel::enqueuePos [protected] |
PMutex PQueueChannel::mutex [protected] |
BYTE* PQueueChannel::queueBuffer [protected] |
PINDEX PQueueChannel::queueLength [protected] |
PINDEX PQueueChannel::queueSize [protected] |
PSyncPoint PQueueChannel::unempty [protected] |
PSyncPoint PQueueChannel::unfull [protected] |