00001 #ifndef BoundedBuffer_HPP 00002 #define BoundedBuffer_HPP 00003 00004 #include "Standard.hpp" 00005 #include "Basic_PThread.hpp" 00006 00007 #define BBSIZE 10 00008 #define STEPS 15 00009 00010 class BoundedBuffer { 00011 private: 00012 size_t size; // Size of the buffer 00013 size_t front; // Front or head position 00014 size_t rear; // Rear or tail position 00015 long count; // Number of items stored 00016 char* buffer; // Buffer containing items 00017 BOOL* empty; // Buffer position x is empty or filled ? 00018 00019 public: 00020 BoundedBuffer( size_t sz = BBSIZE ); 00021 00022 void enqueue( char item ); 00023 char dequeue(); 00024 00025 inline long getCount() { return count; } 00026 inline size_t getSize() { return size; } 00027 inline BOOL isEmpty() { return (count == 0); } 00028 }; 00029 00030 #endif