lmsg/BufferPool.hh

00001 /* -*- mode: c++; c-basic-offset: 4; -*- */
00002 #ifndef LMSG_BUFFERPOOL_HH
00003 #define LMSG_BUFFERPOOL_HH
00004 #include "lmsg/MsgTypes.hh"
00005 #include "gmutex.hh"
00006 #include <list>
00007 
00008 #define DEFAULTBUFFERPOOLSIZE  65536
00009 #define DEFAULTBUFFERPOOLCOUNT    16
00010 
00011 namespace lmsg {
00012     class Buffer;
00013 
00022     class BufferPool {
00023     public:
00029         ~BufferPool(void);
00030 
00037         BufferPool(size_type number, size_type length);
00038 
00043         Buffer* getBuffer(void);
00044 
00049         void    returnBuffer(Buffer* buff);
00050 
00055         size_type  getLength(void) const;
00056 
00062         size_type  getDataLength(void) const;
00063 
00064     private:
00065         typedef std::list<Buffer*> PoolList;
00066         typedef PoolList::iterator Pool_Iter;
00067 
00068     private:
00069         size_type   mLength;
00070         size_type   mCount;
00071         PoolList mPool;
00072         thread::mutex mMux;
00073     }; // Buffer class
00074 
00075     inline size_type
00076     BufferPool::getLength(void) const {
00077         return mLength;
00078     }
00079 
00080 } // namespace lmsg
00081 
00084 extern lmsg::BufferPool defaultLMsgBufferPool;
00085 
00086 #endif // LMSG_BUFFER_HH

Generated on Sun Mar 8 19:20:49 2009 for dmt by  doxygen 1.5.4