Go to the documentation of this file.
28 #ifndef CASA_LOCKFILE_H
29 #define CASA_LOCKFILE_H
33 #include <casacore/casa/aips.h>
34 #include <casacore/casa/IO/FileLocker.h>
35 #include <casacore/casa/OS/Time.h>
36 #include <casacore/casa/Containers/Block.h>
37 #include <casacore/casa/BasicSL/String.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);
void addReqId()
Add the request id of this process to the list.
Bool hasLock(LockType=Write) const
Test if the process has a lock for read or write on the file.
Bool canLock(LockType=Write)
Test if the file can be locked for read or write.
void getInfo(MemoryIO &info)
Get the request id's and the info from the lock file.
date and time enquiry functions, with some operations.
void convReqId(const uChar *buffer, uInt leng)
Convert the request id from canonical to local format.
Bool canLock(FileLocker::LockType=FileLocker::Write)
Test if the file can be locked for read or write.
~LockFile()
The destructor does not delete the file, because it is not known when the last process using the lock...
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.
Class to handle file locking and synchronization.
LockType
Define the possible lock types.
Class for IO in canonical format.
Class for IO to a memory buffer.
void getReqId()
Get the request list from the file.
Class for unbuffered IO on a file.
Bool isMultiUsed()
Is the file associated with the LockFile object in use in another process?
String lastMessage() const
Get the message belonging to the last error.
int lastError() const
Get the last error.
Bool acquire(FileLocker::LockType=FileLocker::Write, uInt nattempts=0)
Acquire a read or write lock.
@ Write
Acquire a write lock.
String lastMessage() const
Get the message belonging to the last error.
Bool release()
Release a lock and write the information (if given) into the lock file.
const String & name() const
Get the name of the lock file.
void removeReqId()
Remove the request id of this process from the list (and all the ones before it).
int lastError() const
Get the last error.
this file contains all the compiler specific defines
void putInfo(const MemoryIO &info) const
Put the info into the file (after the request id's).
void putReqId(int fd) const
Put the request list into the file.
Bool inspect(Bool always=False)
Inspect if another process wants to access the file (i.e.
const Block< Int > & reqIds() const
Get the block of request id's.
String: the storage and methods of handling collections of characters.
Class to handle file locking.
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.
bool Bool
Define the standard types used by Casacore.
LockFile & operator=(const LockFile &)
Assignment cannot be used (its semantics are too difficult).
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 hasLock(FileLocker::LockType=FileLocker::Write) const
Test if the process has a lock for read or write on the file.
Int getNrReqId() const
Get the number of request id's.