KaliVeda
Toolkit for HIC analysis
KVLockfile.h
1 /*
2 $Id: KVLockfile.h,v 1.1 2008/02/07 09:25:40 franklan Exp $
3 $Revision: 1.1 $
4 $Date: 2008/02/07 09:25:40 $
5 */
6 
9 
10 #ifndef __KVLOCKFILE_H
11 #define __KVLOCKFILE_H
12 
13 #include "KVString.h"
14 
70 class KVLockfile {
73  bool have_exec;
74  int sleeptime;
75  int retries;
77  int suspend;
79  bool locked;
80 
81  void init();
82  int testlock();
83  void writecmd();
84  Bool_t FindExecutable(TString& exec, const Char_t* path = "$(PATH)");
85 
86 public:
87  KVLockfile(const Char_t* filename = "");
88  virtual ~KVLockfile();
89 
90  void SetSleeptime(int s)
91  {
92  sleeptime = s;
93  };
94  void SetRetries(int r)
95  {
96  retries = r;
97  };
98  void SetTimeout(int t)
99  {
100  locktimeout = t;
101  };
102  void SetSuspend(int s)
103  {
104  suspend = s;
105  };
106 
107  Bool_t Lock(const Char_t* filename = "");
108  Bool_t Release();
109 
110  Bool_t IsLocked() const
111  {
112  return locked;
113  };
114 
115  ClassDef(KVLockfile, 1) //Interface to (Linux) system lockfile command
116 };
117 
118 #endif
ROOT::R::TRInterface & r
bool Bool_t
char Char_t
#define ClassDef(name, id)
Interface to (Linux) system lockfile command.
Definition: KVLockfile.h:70
Bool_t FindExecutable(TString &exec, const Char_t *path="$(PATH)")
copied from KVBase to avoid circular dependency
Definition: KVLockfile.cpp:75
void SetSleeptime(int s)
Definition: KVLockfile.h:90
Bool_t Release()
Definition: KVLockfile.cpp:195
int locktimeout
time after which lock automatically opens
Definition: KVLockfile.h:76
int retries
number of times to retry
Definition: KVLockfile.h:75
KVString fFile
name of file
Definition: KVLockfile.h:71
bool locked
kTRUE when Lock() has been called successfully
Definition: KVLockfile.h:79
int testlock()
Definition: KVLockfile.cpp:152
virtual ~KVLockfile()
Definition: KVLockfile.cpp:39
int sleeptime
time to wait before retrying lock
Definition: KVLockfile.h:74
void writecmd()
Writes lockfile command with current values of parameters.
Definition: KVLockfile.cpp:122
int suspend
suspend time after timeout
Definition: KVLockfile.h:77
KVString fLockfile
full path to lockfile executable (if defined)
Definition: KVLockfile.h:72
void SetTimeout(int t)
Definition: KVLockfile.h:98
Bool_t Lock(const Char_t *filename="")
Definition: KVLockfile.cpp:165
KVString cmd
command to execute
Definition: KVLockfile.h:78
void SetRetries(int r)
Definition: KVLockfile.h:94
KVLockfile(const Char_t *filename="")
Default constructor.
Definition: KVLockfile.cpp:25
Bool_t IsLocked() const
Definition: KVLockfile.h:110
bool have_exec
kTRUE if lockfile found on system
Definition: KVLockfile.h:73
void init()
Definition: KVLockfile.cpp:55
void SetSuspend(int s)
Definition: KVLockfile.h:102
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:73