9 #ifndef __libutilxx__sella__util__LockFile_H__
10 #define __libutilxx__sella__util__LockFile_H__
12 #include "../../common.h"
13 #include "FileException.h"
17 #include <sys/types.h>
21 #include <sys/types.h>
38 static const useconds_t RetryInterval = 100000;
41 LockFile(
const std::string &fullpath, useconds_t staleAge = -1,
bool removeStale =
true, uid_t uid = -1, gid_t gid = -1,
int mode = 0644)
throw ();
44 void setRemoveStale(
bool on =
true);
45 void setStaleAge(useconds_t staleAge = -1)
throw ();
46 void setUID(uid_t uid = -1)
throw ();
47 void setGID(gid_t gid = -1)
throw ();
48 void setMode(
int mode = 0644)
throw ();
50 bool lock(useconds_t retryInterval = RetryInterval)
throw (FileException);
51 bool tryLock(
void)
throw (FileException);
52 bool tryLockUntil(time_t timeout, useconds_t retryInterval = RetryInterval)
throw (FileException);
53 bool tryLockFor(time_t duration, useconds_t retryInterval = RetryInterval)
throw (FileException);
54 bool tryLockCount(int64_t retries, useconds_t retryInterval = RetryInterval)
throw (FileException);
55 bool unlock(
void)
throw (FileException);
56 bool remove(void)
throw ();
58 bool ownLock(
void)
throw ();
59 bool isLocked(
void)
throw ();
60 bool isStale(
void)
throw ();
63 bool lock_nonblock(
void)
throw (FileException);
64 bool unlink(
void)
throw ();
65 void close(
void)
throw ();