28 #ifndef CASA_LOCKFILE_H
29 #define CASA_LOCKFILE_H
38 #include <sys/types.h>
197 explicit LockFile (
const String& fileName,
double inspectInterval = 0,
341 return acquire (0, type, nattempts);
346 return acquire (&info, type, nattempts);
static uInt showLock(uInt &pid, Bool &permLocked, const String &fileName)
Tell if another process holds a read or write lock on the given file or has the file opened...
void putInfo(const MemoryIO &info) const
Put the info into the file (after the request id's).
~LockFile()
The destructor does not delete the file, because it is not known when the last process using the lock...
void getInfo(MemoryIO &info)
Get the request id's and the info from the lock file.
void getReqId()
Get the request list from the file.
int lastError() const
Get the last error.
int lastError() const
Get the last error.
String lastMessage() const
Get the message belonging to the last error.
Class to handle file locking.
const String & name() const
Get the name of the lock file.
const Block< Int > & reqIds() const
Get the block of request id's.
void convReqId(const uChar *buffer, uInt leng)
Convert the request id from canonical to local format.
Class for unbuffered IO on a file.
Bool release()
Release a lock and write the information (if given) into the lock file.
Bool isMultiUsed()
Is the file associated with the LockFile object in use in another process?
Int getNrReqId() const
Get the number of request id's.
Class to handle file locking and synchronization.
Class for IO in canonical format.
date and time enquiry functions, with some operations.
bool Bool
Define the standard types used by Casacore.
void removeReqId()
Remove the request id of this process from the list (and all the ones before it). ...
String lastMessage() const
Get the message belonging to the last error.
LockFile & operator=(const LockFile &)
Assignment cannot be used (its semantics are too difficult).
Bool hasLock(FileLocker::LockType=FileLocker::Write) const
Test if the process has a lock for read or write on the file.
Bool acquire(FileLocker::LockType=FileLocker::Write, uInt nattempts=0)
Acquire a read or write lock.
Int getInt(const uChar *buffer, uInt leng, uInt offset) const
Get an Int from the buffer at the given offset and convert it from canonical to local format...
Bool inspect(Bool always=False)
Inspect if another process wants to access the file (i.e.
Bool canLock(LockType=Write)
Test if the file can be locked for read or write.
String: the storage and methods of handling collections of characters.
Class for IO to a memory buffer.
void putReqId(int fd) const
Put the request list into the file.
Bool hasLock(LockType=Write) const
Test if the process has a lock for read or write on the file.
LockType
Define the possible lock types.
LockFile(const String &fileName, double inspectInterval=0, Bool create=False, Bool addToRequestList=True, Bool mustExist=True, uInt seqnr=0, Bool permLocking=False, Bool noLocking=False)
Create or open the lock file with the given name.
void addReqId()
Add the request id of this process to the list.
Bool canLock(FileLocker::LockType=FileLocker::Write)
Test if the file can be locked for read or write.