00001 /*****************************************************************************/ 00002 /* */ 00003 /* XrdMonBufferedOutput.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: XrdMonBufferedOutput.hh 22437 2008-03-04 14:35:16Z rdm $ 00012 00013 #ifndef XRDMONBUFFEREDOUTPUT_HH 00014 #define XRDMONBUFFEREDOUTPUT_HH 00015 00016 #include "XrdSys/XrdSysPthread.hh" 00017 #include <string> 00018 using std::string; 00019 00020 class XrdMonBufferedOutput { 00021 public: 00022 XrdMonBufferedOutput(const char* outFileName, 00023 const char* lockFileName, 00024 int bufSize); 00025 ~XrdMonBufferedOutput(); 00026 00027 void add(const char* s); 00028 void flush(bool lockMutex=true); 00029 00030 private: 00031 char* _fName; 00032 char* _fNameLock; 00033 00034 char* _buf; 00035 const int _bufSize; // flush when buffer is full, or when 00036 // triggered by external thread 00037 XrdSysMutex _mutex; 00038 }; 00039 00040 #endif /* XRDMONBUFFEREDOUTPUT_HH */