XrdMonCtrBuffer.hh

Go to the documentation of this file.
00001 /*****************************************************************************/
00002 /*                                                                           */
00003 /*                            XrdMonCtrBuffer.hh                             */
00004 /*                                                                           */
00005 /* (c) 2005 by the Board of Trustees of the Leland Stanford, Jr., University */
00006 /*                            All Rights Reserved                            */
00007 /*       Produced by Jacek Becla for Stanford University under contract      */
00008 /*              DE-AC02-76SF00515 with the Department of Energy              */
00009 /*****************************************************************************/
00010 
00011 // $Id: XrdMonCtrBuffer.hh 22437 2008-03-04 14:35:16Z rdm $
00012 
00013 #ifndef XRDMONCTRBUFFER_HH
00014 #define XRDMONCTRBUFFER_HH
00015 
00016 #include "XrdSys/XrdSysPthread.hh"
00017 class XrdMonCtrPacket;
00018 
00019 // It is a fast and simple list: elements are added 
00020 // at the tail when they are received. 
00021 // Archiver retrives them from the head.
00022 // Multithreaded safe. It is a singleton.
00023 
00024 class XrdMonCtrBuffer {
00025 public:
00026     static XrdMonCtrBuffer* instance();
00027     void push_back(XrdMonCtrPacket* p);
00028     XrdMonCtrPacket* pop_front();
00029     void printList(const char*);
00030     
00031 private:
00032     XrdMonCtrBuffer();
00033     void collectStats();
00034 
00035 private:
00036     struct Elem {
00037         Elem(XrdMonCtrPacket* p) : packet(p), next(0) {}
00038         XrdMonCtrPacket* packet;
00039         Elem*   next;
00040     };
00041 
00042     Elem* _head;
00043     Elem* _tail;
00044     int   _noElems;
00045     
00046     XrdSysMutex    _mutex;
00047     XrdSysCondVar  _cond;
00048 
00049     // statistics
00050     int _max;        // maximum _noElems in the list
00051     int _aver;       // average noElems in the list
00052     int _noKInAver;  // no of elements [in 1000s] used to calculate average
00053     int _last1Kmax;  // max noElems in the list, last 0-1000 pop_front()
00054     int _last1Ktotal;// total number of noElems, last 0-1000 pop_front()
00055     int _counter1K;  // number of pop_front() in the "last1K"
00056 
00057     static XrdMonCtrBuffer* _instance;
00058 };
00059 
00060 #endif /* XRDMONCTRBUFFER_HH */

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