TLockFile.h

Go to the documentation of this file.
00001 // @(#)root/io:$Id: TLockFile.h 36484 2010-11-02 16:00:10Z rdm $
00002 // Author: Jan Fiete Grosse-Oetringhaus, 04.06.07
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TLockFile
00013 #define ROOT_TLockFile
00014 
00015 //////////////////////////////////////////////////////////////////////////
00016 //                                                                      //
00017 // TLockFile                                                            //
00018 //                                                                      //
00019 // Lock an object using a file.                                         //
00020 // Constructor blocks until lock is obtained. Lock is released in the   //
00021 // destructor.                                                          //
00022 //                                                                      //
00023 // Use it in scope-blocks like:                                         //
00024 // {                                                                    //
00025 //    TLockFile lock("path.to.lock.file");                              //
00026 //    // do something you need the lock for                             //
00027 // } // lock is automatically released                                  //
00028 //                                                                      //
00029 //////////////////////////////////////////////////////////////////////////
00030 
00031 #ifndef ROOT_TObject
00032 #include "TObject.h"
00033 #endif
00034 #ifndef ROOT_TString
00035 #include "TString.h"
00036 #endif
00037 
00038 
00039 class TLockFile : public TObject {
00040 
00041 private:
00042    TLockFile(const TLockFile&);             // not implemented
00043    TLockFile& operator=(const TLockFile&);  // not implemented
00044 
00045 protected:
00046    TString fPath;         // path to file holding the lock
00047 
00048    Bool_t Lock(const char *path, Int_t timeLimit);
00049 
00050 public:
00051    TLockFile(const char *path, Int_t timeLimit = 0);
00052    virtual ~TLockFile();
00053 
00054    ClassDef(TLockFile, 0) //Lock an object using a file
00055 };
00056 
00057 #endif

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