KaliVeda  1.13/01
Heavy-Ion Analysis Toolkit
KVLockfile.h
Go to the documentation of this file.
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 
69 class KVLockfile {
72  bool have_exec;
73  int sleeptime;
74  int retries;
76  int suspend;
78  bool locked;
79 
80  void init();
81  int testlock();
82  void writecmd();
83  Bool_t FindExecutable(TString& exec, const Char_t* path = "$(PATH)");
84 
85 public:
86  KVLockfile(const Char_t* filename = "");
87  virtual ~KVLockfile();
88 
89  void SetSleeptime(int s)
90  {
91  sleeptime = s;
92  };
93  void SetRetries(int r)
94  {
95  retries = r;
96  };
97  void SetTimeout(int t)
98  {
99  locktimeout = t;
100  };
101  void SetSuspend(int s)
102  {
103  suspend = s;
104  };
105 
106  Bool_t Lock(const Char_t* filename = "");
107  Bool_t Release();
108 
109  Bool_t IsLocked() const
110  {
111  return locked;
112  };
113 
114  ClassDef(KVLockfile, 1) //Interface to (Linux) system lockfile command
115 };
116 
117 #endif
ROOT::R::TRInterface & r
char Char_t
bool Bool_t
#define ClassDef(name, id)
Interface to (Linux) system lockfile command.
Definition: KVLockfile.h:69
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:89
Bool_t Release()
Definition: KVLockfile.cpp:195
int locktimeout
time after which lock automatically opens
Definition: KVLockfile.h:75
int retries
number of times to retry
Definition: KVLockfile.h:74
KVString fFile
name of file
Definition: KVLockfile.h:70
bool locked
kTRUE when Lock() has been called successfully
Definition: KVLockfile.h:78
int testlock()
Definition: KVLockfile.cpp:152
virtual ~KVLockfile()
Definition: KVLockfile.cpp:39
int sleeptime
time to wait before retrying lock
Definition: KVLockfile.h:73
void writecmd()
Writes lockfile command with current values of parameters.
Definition: KVLockfile.cpp:122
int suspend
suspend time after timeout
Definition: KVLockfile.h:76
KVString fLockfile
full path to lockfile executable (if defined)
Definition: KVLockfile.h:71
void SetTimeout(int t)
Definition: KVLockfile.h:97
Bool_t Lock(const Char_t *filename="")
Definition: KVLockfile.cpp:165
KVString cmd
command to execute
Definition: KVLockfile.h:77
void SetRetries(int r)
Definition: KVLockfile.h:93
KVLockfile(const Char_t *filename="")
Default constructor.
Definition: KVLockfile.cpp:25
Bool_t IsLocked() const
Definition: KVLockfile.h:109
bool have_exec
kTRUE if lockfile found on system
Definition: KVLockfile.h:72
void init()
Definition: KVLockfile.cpp:55
void SetSuspend(int s)
Definition: KVLockfile.h:101
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:72
const long double s
Definition: KVUnits.h:94