Logo ROOT   6.07/09
Reference Guide
TLockPath.h
Go to the documentation of this file.
1 // @(#)root/proof:$Id$
2 // Author: G. Ganis, Oct 2015
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TLockPath
13 #define ROOT_TLockPath
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TLockPath //
18 // //
19 // Path locking class allowing shared and exclusive locks //
20 // //
21 //////////////////////////////////////////////////////////////////////////
22 
23 #ifndef ROOT_TObject
24 #include "TObject.h"
25 #endif
26 #ifndef ROOT_TString
27 #include "TString.h"
28 #endif
29 
30 class TLockPath : public TObject {
31 private:
32  TString fName; // path to lock
33  Int_t fLockId; // file id of dir lock
34 
35 public:
36  TLockPath(const char *path = "");
37  ~TLockPath() { if (IsLocked()) Unlock(); }
38 
39  const char *GetName() const { return fName; }
40  void SetName(const char *path) { fName = path; }
41 
42  Int_t Lock(Bool_t shared = kFALSE);
43  Int_t Unlock();
44 
45  Bool_t IsLocked() const { return (fLockId > -1); }
46 
47  ClassDef(TLockPath, 0) // Path locking class
48 };
49 
51 private:
52  TLockPath *fLocker; //locker instance
53 
54 public:
56  fLocker = l; fLocker->Lock(shared); }
57  ~TLockPathGuard() { fLocker->Unlock(); }
58 };
59 
60 #endif
Int_t Unlock()
Unlock the directory.
Definition: TLockPath.cxx:71
Int_t Lock(Bool_t shared=kFALSE)
Definition: TLockPath.cxx:34
TLockPath * fLocker
Definition: TLockPath.h:52
const char * GetName() const
Returns name of object.
Definition: TLockPath.h:39
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
~TLockPath()
Definition: TLockPath.h:37
Path locking class allowing shared and exclusive locks.
Definition: TLockPath.h:30
#define ClassDef(name, id)
Definition: Rtypes.h:254
Bool_t IsLocked() const
Definition: TLockPath.h:45
TString fName
Definition: TLockPath.h:32
void SetName(const char *path)
Definition: TLockPath.h:40
TLine * l
Definition: textangle.C:4
Int_t fLockId
Definition: TLockPath.h:33
Mother of all ROOT objects.
Definition: TObject.h:44
TLockPath(const char *path="")
Locks the directory.
Definition: TLockPath.cxx:27
TLockPathGuard(TLockPath *l, Bool_t shared=kFALSE)
Definition: TLockPath.h:55