ui-utilcpp 1.10.1
Public Member Functions
UI::Util::PosixFileMutex Class Reference

Mutex For Posix Advisory File Locking. More...

#include <File.hpp>

Inheritance diagram for UI::Util::PosixFileMutex:
Inheritance graph
Collaboration diagram for UI::Util::PosixFileMutex:
Collaboration graph

Public Member Functions

 PosixFileMutex (std::string const &lockFile)
 Constructor from file name. More...
 
 PosixFileMutex (int fd)
 Constructor from file descriptor. More...
 
Standard mutex methods.
bool tryEnterMutex () throw ()
 
void enterMutex ()
 
void leaveMutex ()
 
- Public Member Functions inherited from UI::Util::File
 File (std::string const &name, int flags=O_CREAT|O_WRONLY, mode_t mode=S_IRUSR|S_IWUSR, bool closeFd=true)
 Constructor. More...
 
 File (int fd, bool closeFd=false)
 Constructor from file descriptor. More...
 
std::string const & getName () const
 Get file name. This will always deliver en empty string if constructed from fd.
 
- Public Member Functions inherited from UI::Util::FileDescriptor
 FileDescriptor (int fd=-1, bool closeFd=false)
 Constructor from file descriptor. More...
 
virtual ~FileDescriptor ()
 Destructor. More...
 
virtual std::streamsize read (void *const buf, std::streamsize count)
 C++ like virtual read method. More...
 
virtual std::streamsize write (void const *const buf, std::streamsize count)
 C++ like virtual erite method. More...
 
int getFd () const
 Get file descriptor.
 

Additional Inherited Members

- Public Types inherited from UI::Util::FileDescriptor
enum  ErrorCode {
  OpenErr_ = 1 , ReadErr_ , WriteErr_ , LockErr_ ,
  UnlockErr_ , BindErr_ , ConnectErr_ , UnblockErr_ ,
  ListenErr_ , ShutdownErr_
}
 Error codes for exceptions.
 
typedef CodeException< ErrorCodeException
 Exceptions for this class.
 
- Static Public Member Functions inherited from UI::Util::FileDescriptor
static void fdClose (int const &fd, std::string const &id, bool const &doClose=true)
 Helper to close file descriptors from destructors.
 
- Protected Member Functions inherited from UI::Util::FileDescriptor
void init (int fd, bool closeFd=false)
 To be called in a constructor.
 
- Protected Attributes inherited from UI::Util::FileDescriptor
int fd_
 The file descriptor that is managed.
 

Detailed Description

Mutex For Posix Advisory File Locking.

See also
MutexLock
fcntl(2), open(2)
Attention
This does not work from the same process id, as any close() to any open file descriptor of a process removes all POSIX locks from that (process/fd)-pair.
Examples
FileLock.cpp.

Constructor & Destructor Documentation

◆ PosixFileMutex() [1/2]

UI::Util::PosixFileMutex::PosixFileMutex ( std::string const &  lockFile)

Constructor from file name.

Parameters
lockFileName of lock file
See also
FileDescriptor

◆ PosixFileMutex() [2/2]

UI::Util::PosixFileMutex::PosixFileMutex ( int  fd)

Constructor from file descriptor.

Parameters
fdOpened file descriptor
See also
FileDescriptor

The documentation for this class was generated from the following files: