/* ======================================================================== * BoundedBuffer.H * ------------------------------------------------------------------------ * Interface file for the BoundedBuffer classes, BoundedBuffer, BBConsumer, * and BBProducer. * * Copyright 1997-1998 by G. Wade Johnson (Telescan, Inc.) * Use of this code is placed in the public domain as long as the * copyright notice is retained. */ #if !defined( INCLUDED_BOUNDEDBUFFER ) #define INCLUDED_BOUNDEDBUFFER #if !defined( INCLUDED_WINDOWS ) #include #define INCLUDED_WINDOWS #endif #if !defined( INCLUDED_SYNCWRAPPER ) #include "SyncWrapper.h" #endif #if !defined( INCLUDED_STRING ) #include #define INCLUDED_STRING #endif class CriticalSection; class Semaphore; class BoundedBuffer { short myBufferSize; std::string myName; CriticalSection *mypBufferMutex; Semaphore *mypFullSem; Semaphore *mypEmptySem; public: BoundedBuffer( short size ); BoundedBuffer( short size, const char *name ); ~BoundedBuffer(); const std::string &getName() const { return myName; } void BeginGet(); void EndGet(); void BeginPut(); void EndPut(); } ; class BBConsumer : public SyncWrapper { public: BBConsumer( BoundedBuffer &bb ) : SyncWrapper(bb,BoundedBuffer::BeginGet,BoundedBuffer::EndGet) { } ~BBConsumer() { } } ; class BBProducer : public SyncWrapper { public: BBProducer( BoundedBuffer &bb ) : SyncWrapper(bb,BoundedBuffer::BeginPut,BoundedBuffer::EndPut) { } ~BBProducer() { } } ; #endif