XrdNetBuffer.hh

Go to the documentation of this file.
00001 #ifndef __NET_BUFF__
00002 #define __NET_BUFF__
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                       X r d N e t B u f f e r . h h                        */
00006 /*                                                                            */
00007 /* (c) 2003 by the Board of Trustees of the Leland Stanford, Jr., University  */
00008 /*                            All Rights Reserved                             */
00009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00010 /*              DE-AC03-76-SFO0515 with the Department of Energy              */
00011 /******************************************************************************/
00012   
00013 //          $Id: XrdNetBuffer.hh 22437 2008-03-04 14:35:16Z rdm $
00014 
00015 #include <stdlib.h>
00016 
00017 #include "XrdOuc/XrdOucChain.hh"
00018 #include "XrdSys/XrdSysPthread.hh"
00019 
00020 /******************************************************************************/
00021 /*                         X r d N e t B u f f e r Q                          */
00022 /******************************************************************************/
00023 
00024 class XrdNetBuffer;
00025   
00026 class XrdNetBufferQ
00027 {
00028 public:
00029 
00030        XrdNetBuffer  *Alloc();
00031 
00032 inline int            BuffSize(void) {return size;}
00033 
00034        void           Recycle(XrdNetBuffer *bp);
00035 
00036        void           Set(int maxb);
00037 
00038        XrdNetBufferQ(int bsz, int maxb=16);
00039       ~XrdNetBufferQ();
00040 
00041        int                       alignit;
00042        XrdSysMutex               BuffList;
00043        XrdOucStack<XrdNetBuffer> BuffStack;
00044        int                       maxbuff;
00045        int                       numbuff;
00046        int                       size;
00047 };
00048 
00049 /******************************************************************************/
00050 /*                          X r d N e t B u f f e r                           */
00051 /******************************************************************************/
00052 
00053 class XrdNetBuffer
00054 {
00055 friend class XrdNetBufferQ;
00056 
00057 public:
00058        char         *data;
00059        int           dlen;
00060 
00061 inline int           BuffSize(void) {return BuffQ->BuffSize();}
00062 
00063        void          Recycle(void)  {BuffQ->Recycle(this);}
00064 
00065       XrdNetBuffer(XrdNetBufferQ *bq);
00066      ~XrdNetBuffer() {if (data) free(data);}
00067 
00068 private:
00069 
00070       XrdOucQSItem<XrdNetBuffer> BuffLink;
00071       XrdNetBufferQ             *BuffQ;
00072 };
00073 #endif

Generated on Tue Jul 5 14:46:43 2011 for ROOT_528-00b_version by  doxygen 1.5.1