qchannel.h
Go to the documentation of this file.
/*
* qchannel.h
*
* Class for implementing a serial queue channel in memory.
*
* Portable Windows Library
*
* Copyright (c) 2001 Equivalence Pty. Ltd.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Portable Windows Library.
*
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
*
* Contributor(s): ______________________________________.
*
* $Revision: 24177 $
* $Author: rjongbloed $
* $Date: 2010-04-05 06:52:04 -0500 (Mon, 05 Apr 2010) $
*/
#ifndef PTLIB_QCHANNEL_H
#define PTLIB_QCHANNEL_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
class PQueueChannel : public PChannel
{
PCLASSINFO(PQueueChannel, PChannel);
public:
PQueueChannel(
PINDEX queueSize = 0
);
~PQueueChannel();
virtual PBoolean Read(
void * buf,
PINDEX len
);
virtual PBoolean Write(
const void * buf,
PINDEX len
);
virtual PBoolean Close();
virtual PBoolean Open(
PINDEX queueSize
);
PINDEX GetSize() const { return queueSize; }
PINDEX GetLength() const { return queueLength; }
protected:
PMutex mutex;
BYTE * queueBuffer;
PINDEX queueSize, queueLength, enqueuePos, dequeuePos;
PSyncPoint unempty;
PSyncPoint unfull;
};
#endif // PTLIB_QCHANNEL_H
// End Of File ///////////////////////////////////////////////////////////////
PQueueChannel::PQueueChannel
PQueueChannel(PINDEX queueSize=0)
Create a new queue channel with the specified maximum size.
PQueueChannel::unempty
PSyncPoint unempty
Definition: qchannel.h:129
PQueueChannel::queueSize
PINDEX queueSize
Definition: qchannel.h:128
PQueueChannel::GetSize
PINDEX GetSize() const
Get the queue size.
Definition: qchannel.h:119
PQueueChannel::~PQueueChannel
~PQueueChannel()
Delete queue and release memory used.
PQueueChannel::mutex
PMutex mutex
Definition: qchannel.h:126
PQueueChannel::dequeuePos
PINDEX dequeuePos
Definition: qchannel.h:128
PQueueChannel::queueLength
PINDEX queueLength
Definition: qchannel.h:128
PQueueChannel::Open
virtual PBoolean Open(PINDEX queueSize)
Open a queue, allocating the queueSize bytes.
PQueueChannel::unfull
PSyncPoint unfull
Definition: qchannel.h:130
PBoolean
BOOL PBoolean
Definition: object.h:102
PQueueChannel::enqueuePos
PINDEX enqueuePos
Definition: qchannel.h:128
PQueueChannel::GetLength
PINDEX GetLength() const
Get the current queue length.
Definition: qchannel.h:122
PQueueChannel::Read
virtual PBoolean Read(void *buf, PINDEX len)
Low level read from the file channel.
PQueueChannel::queueBuffer
BYTE * queueBuffer
Definition: qchannel.h:127
PChannel
Abstract class defining I/O channel semantics.
Definition: channel.h:107
PQueueChannel
Class for implementing a serial queue channel in memory.
Definition: qchannel.h:53
PQueueChannel::Write
virtual PBoolean Write(const void *buf, PINDEX len)
Low level write to the file channel.
PQueueChannel::Close
virtual PBoolean Close()
Close the file channel.
PMutex
Synonym for PTimedMutex.
PSyncPoint
This class defines a thread synchronisation object.
Definition: syncpoint.h:67