From 32b3ed0a1362a4b0798ad71fac3450fb77cb7e41 Mon Sep 17 00:00:00 2001 From: Thomas Groman Date: Thu, 19 Sep 2019 00:41:48 -0700 Subject: merged from 0.6.7 codebase --- libraries/LocalPeer/src/LockedFile.cpp | 152 ++++++++++++++++----------------- 1 file changed, 76 insertions(+), 76 deletions(-) (limited to 'libraries/LocalPeer/src/LockedFile.cpp') diff --git a/libraries/LocalPeer/src/LockedFile.cpp b/libraries/LocalPeer/src/LockedFile.cpp index a4951bfe..73294a16 100644 --- a/libraries/LocalPeer/src/LockedFile.cpp +++ b/libraries/LocalPeer/src/LockedFile.cpp @@ -41,70 +41,70 @@ #include "LockedFile.h" /*! - \class QtLockedFile - - \brief The QtLockedFile class extends QFile with advisory locking - functions. - - A file may be locked in read or write mode. Multiple instances of - \e QtLockedFile, created in multiple processes running on the same - machine, may have a file locked in read mode. Exactly one instance - may have it locked in write mode. A read and a write lock cannot - exist simultaneously on the same file. - - The file locks are advisory. This means that nothing prevents - another process from manipulating a locked file using QFile or - file system functions offered by the OS. Serialization is only - guaranteed if all processes that access the file use - QLockedFile. Also, while holding a lock on a file, a process - must not open the same file again (through any API), or locks - can be unexpectedly lost. - - The lock provided by an instance of \e QtLockedFile is released - whenever the program terminates. This is true even when the - program crashes and no destructors are called. + \class QtLockedFile + + \brief The QtLockedFile class extends QFile with advisory locking + functions. + + A file may be locked in read or write mode. Multiple instances of + \e QtLockedFile, created in multiple processes running on the same + machine, may have a file locked in read mode. Exactly one instance + may have it locked in write mode. A read and a write lock cannot + exist simultaneously on the same file. + + The file locks are advisory. This means that nothing prevents + another process from manipulating a locked file using QFile or + file system functions offered by the OS. Serialization is only + guaranteed if all processes that access the file use + QLockedFile. Also, while holding a lock on a file, a process + must not open the same file again (through any API), or locks + can be unexpectedly lost. + + The lock provided by an instance of \e QtLockedFile is released + whenever the program terminates. This is true even when the + program crashes and no destructors are called. */ /*! \enum QtLockedFile::LockMode - This enum describes the available lock modes. + This enum describes the available lock modes. - \value ReadLock A read lock. - \value WriteLock A write lock. - \value NoLock Neither a read lock nor a write lock. + \value ReadLock A read lock. + \value WriteLock A write lock. + \value NoLock Neither a read lock nor a write lock. */ /*! - Constructs an unlocked \e QtLockedFile object. This constructor - behaves in the same way as \e QFile::QFile(). + Constructs an unlocked \e QtLockedFile object. This constructor + behaves in the same way as \e QFile::QFile(). - \sa QFile::QFile() + \sa QFile::QFile() */ LockedFile::LockedFile() - : QFile() + : QFile() { #ifdef Q_OS_WIN - wmutex = 0; - rmutex = 0; + wmutex = 0; + rmutex = 0; #endif - m_lock_mode = NoLock; + m_lock_mode = NoLock; } /*! - Constructs an unlocked QtLockedFile object with file \a name. This - constructor behaves in the same way as \e QFile::QFile(const - QString&). + Constructs an unlocked QtLockedFile object with file \a name. This + constructor behaves in the same way as \e QFile::QFile(const + QString&). - \sa QFile::QFile() + \sa QFile::QFile() */ LockedFile::LockedFile(const QString &name) - : QFile(name) + : QFile(name) { #ifdef Q_OS_WIN - wmutex = 0; - rmutex = 0; + wmutex = 0; + rmutex = 0; #endif - m_lock_mode = NoLock; + m_lock_mode = NoLock; } /*! @@ -122,72 +122,72 @@ Returns true if successful; otherwise false. */ bool LockedFile::open(OpenMode mode) { - if (mode & QIODevice::Truncate) { - qWarning("QtLockedFile::open(): Truncate mode not allowed."); - return false; - } - return QFile::open(mode); + if (mode & QIODevice::Truncate) { + qWarning("QtLockedFile::open(): Truncate mode not allowed."); + return false; + } + return QFile::open(mode); } /*! - Returns \e true if this object has a in read or write lock; - otherwise returns \e false. + Returns \e true if this object has a in read or write lock; + otherwise returns \e false. - \sa lockMode() + \sa lockMode() */ bool LockedFile::isLocked() const { - return m_lock_mode != NoLock; + return m_lock_mode != NoLock; } /*! - Returns the type of lock currently held by this object, or \e - QtLockedFile::NoLock. + Returns the type of lock currently held by this object, or \e + QtLockedFile::NoLock. - \sa isLocked() + \sa isLocked() */ LockedFile::LockMode LockedFile::lockMode() const { - return m_lock_mode; + return m_lock_mode; } /*! - \fn bool QtLockedFile::lock(LockMode mode, bool block = true) + \fn bool QtLockedFile::lock(LockMode mode, bool block = true) - Obtains a lock of type \a mode. The file must be opened before it - can be locked. + Obtains a lock of type \a mode. The file must be opened before it + can be locked. - If \a block is true, this function will block until the lock is - aquired. If \a block is false, this function returns \e false - immediately if the lock cannot be aquired. + If \a block is true, this function will block until the lock is + aquired. If \a block is false, this function returns \e false + immediately if the lock cannot be aquired. - If this object already has a lock of type \a mode, this function - returns \e true immediately. If this object has a lock of a - different type than \a mode, the lock is first released and then a - new lock is obtained. + If this object already has a lock of type \a mode, this function + returns \e true immediately. If this object has a lock of a + different type than \a mode, the lock is first released and then a + new lock is obtained. - This function returns \e true if, after it executes, the file is - locked by this object, and \e false otherwise. + This function returns \e true if, after it executes, the file is + locked by this object, and \e false otherwise. - \sa unlock(), isLocked(), lockMode() + \sa unlock(), isLocked(), lockMode() */ /*! - \fn bool QtLockedFile::unlock() + \fn bool QtLockedFile::unlock() - Releases a lock. + Releases a lock. - If the object has no lock, this function returns immediately. + If the object has no lock, this function returns immediately. - This function returns \e true if, after it executes, the file is - not locked by this object, and \e false otherwise. + This function returns \e true if, after it executes, the file is + not locked by this object, and \e false otherwise. - \sa lock(), isLocked(), lockMode() + \sa lock(), isLocked(), lockMode() */ /*! - \fn QtLockedFile::~QtLockedFile() + \fn QtLockedFile::~QtLockedFile() - Destroys the \e QtLockedFile object. If any locks were held, they - are released. + Destroys the \e QtLockedFile object. If any locks were held, they + are released. */ -- cgit v1.2.3