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>
341 return acquire (0, type, nattempts);
346 return acquire (&info, type, nattempts);
int lastError() const
Get the last error.
Bool canLock(LockType=Write)
Test if the file can be locked for read or write.
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.
@ Write
Acquire a write lock.
String lastMessage() const
Get the message belonging to the last error.
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.
LockFile(const LockFile &)
The copy constructor cannot be used (its semantics are too difficult).
void putReqId(int fd) const
Put the request list into the file.
const Block< Int > & reqIds() const
Get the block of request id's.
Bool isMultiUsed()
Is the file associated with the LockFile object in use in another process?
void convReqId(const uChar *buffer, uInt leng)
Convert the request id from canonical to local format.
int lastError() const
Get the last error.
void addReqId()
Add the request id of this process to the list.
Bool hasLock(FileLocker::LockType=FileLocker::Write) const
Test if the process has a lock for read or write on the file.
const String & name() const
Get the name of the lock file.
void putInfo(const MemoryIO &info) const
Put the info into the file (after the request id's).
Bool release()
Release a lock and write the information (if given) into the lock file.
Bool canLock(FileLocker::LockType=FileLocker::Write)
Test if the file can be locked for read or write.
Bool inspect(Bool always=False)
Inspect if another process wants to access the file (i.e.
~LockFile()
The destructor does not delete the file, because it is not known when the last process using the lock...
Int getNrReqId() const
Get the number of request id's.
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.
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 getInfo(MemoryIO &info)
Get the request id's and the info from the lock file.
Bool acquire(MemoryIO *info, FileLocker::LockType type, uInt nattempts)
LockFile & operator=(const LockFile &)
Assignment cannot be used (its semantics are too difficult).
String lastMessage() const
Get the message belonging to the last error.
void removeReqId()
Remove the request id of this process from the list (and all the ones before it).
Bool acquire(FileLocker::LockType=FileLocker::Write, uInt nattempts=0)
Acquire a read or write lock.
Bool release(const MemoryIO *info)
void getReqId()
Get the request list from the file.
String: the storage and methods of handling collections of characters.
this file contains all the compiler specific defines
bool Bool
Define the standard types used by Casacore.