Logo ROOT  
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 #include "TObject.h"
24 #include "TString.h"
25 
26 class TLockPath : public TObject {
27 private:
28  TString fName; // path to lock
29  Int_t fLockId; // file id of dir lock
30 
31 public:
32  TLockPath(const char *path = "");
33  ~TLockPath() { if (IsLocked()) Unlock(); }
34 
35  const char *GetName() const { return fName; }
36  void SetName(const char *path) { fName = path; }
37 
38  Int_t Lock(Bool_t shared = kFALSE);
40 
41  Bool_t IsLocked() const { return (fLockId > -1); }
42 
43  ClassDef(TLockPath, 0) // Path locking class
44 };
45 
47 private:
48  TLockPath *fLocker; //locker instance
49 
50 public:
52  fLocker = l; fLocker->Lock(shared); }
54 };
55 
56 #endif
l
auto * l
Definition: textangle.C:4
TLockPath::Unlock
Int_t Unlock()
Unlock the directory.
Definition: TLockPath.cxx:80
TLockPath::Lock
Int_t Lock(Bool_t shared=kFALSE)
Definition: TLockPath.cxx:43
TLockPath::~TLockPath
~TLockPath()
Definition: TLockPath.h:39
Int_t
int Int_t
Definition: RtypesCore.h:45
TLockPath::IsLocked
Bool_t IsLocked() const
Definition: TLockPath.h:47
TLockPath
Definition: TLockPath.h:26
TLockPath::TLockPath
TLockPath(const char *path="")
Locks the directory.
Definition: TLockPath.cxx:36
TString
Definition: TString.h:136
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TString.h
bool
TLockPath::fName
TString fName
Definition: TLockPath.h:34
TLockPath::SetName
void SetName(const char *path)
Definition: TLockPath.h:42
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TLockPathGuard::TLockPathGuard
TLockPathGuard(TLockPath *l, Bool_t shared=kFALSE)
Definition: TLockPath.h:51
TLockPathGuard::fLocker
TLockPath * fLocker
Definition: TLockPath.h:48
TLockPath::GetName
const char * GetName() const
Returns name of object.
Definition: TLockPath.h:41
TLockPath::fLockId
Int_t fLockId
Definition: TLockPath.h:35
TObject.h
TObject
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TLockPathGuard::~TLockPathGuard
~TLockPathGuard()
Definition: TLockPath.h:53
TLockPathGuard
Definition: TLockPath.h:46
int