Commit 865669e9 authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

[1704] Update documentation

parent 58c0a8ef
...@@ -62,10 +62,18 @@ public: ...@@ -62,10 +62,18 @@ public:
protected: protected:
/// \brief Acquire the lock (blocks if something else has acquired a /// \brief Acquire the lock (blocks if something else has acquired a
/// lock on the same task name) /// lock on the same task name)
///
/// \return Returns true if the lock was acquired, false otherwise.
virtual bool lock() = 0; virtual bool lock() = 0;
/// \brief Try to acquire a lock (doesn't block) /// \brief Try to acquire a lock (doesn't block)
///
/// \return Returns true if the lock was acquired, false otherwise.
virtual bool tryLock() = 0; virtual bool tryLock() = 0;
/// \brief Release the lock /// \brief Release the lock
///
/// \return Returns true if the lock was released, false otherwise.
virtual bool unlock() = 0; virtual bool unlock() = 0;
const std::string task_name_; ///< The task name const std::string task_name_; ///< The task name
...@@ -80,6 +88,12 @@ protected: ...@@ -80,6 +88,12 @@ protected:
/// the description of InterprocessSync. /// the description of InterprocessSync.
class InterprocessSyncLocker { class InterprocessSyncLocker {
public: public:
/// \brief Constructor
///
/// Creates a lock manager around a interprocess synchronization object
///
/// \param sync The sync object which has to be locked/unlocked by
/// this locker object.
InterprocessSyncLocker(InterprocessSync& sync) : InterprocessSyncLocker(InterprocessSync& sync) :
sync_(sync) sync_(sync)
{} {}
...@@ -91,16 +105,22 @@ public: ...@@ -91,16 +105,22 @@ public:
/// \brief Acquire the lock (blocks if something else has acquired a /// \brief Acquire the lock (blocks if something else has acquired a
/// lock on the same task name) /// lock on the same task name)
///
/// \return Returns true if the lock was acquired, false otherwise.
bool lock() { bool lock() {
return (sync_.lock()); return (sync_.lock());
} }
/// \brief Try to acquire a lock (doesn't block) /// \brief Try to acquire a lock (doesn't block)
///
/// \return Returns true if the lock was acquired, false otherwise.
bool tryLock() { bool tryLock() {
return (sync_.tryLock()); return (sync_.tryLock());
} }
/// \brief Release the lock /// \brief Release the lock
///
/// \return Returns true if the lock was released, false otherwise.
bool unlock() { bool unlock() {
return (sync_.unlock()); return (sync_.unlock());
} }
......
...@@ -62,18 +62,24 @@ public: ...@@ -62,18 +62,24 @@ public:
protected: protected:
/// \brief Acquire the lock (blocks if something else has acquired a /// \brief Acquire the lock (blocks if something else has acquired a
/// lock on the same task name) /// lock on the same task name)
///
/// \return Returns true if the lock was acquired, false otherwise.
bool lock(); bool lock();
/// \brief Try to acquire a lock (doesn't block) /// \brief Try to acquire a lock (doesn't block)
///
/// \return Returns true if the lock was acquired, false otherwise.
bool tryLock(); bool tryLock();
/// \brief Release the lock /// \brief Release the lock
///
/// \return Returns true if the lock was released, false otherwise.
bool unlock(); bool unlock();
private: private:
bool do_lock(int cmd, short l_type); bool do_lock(int cmd, short l_type);
int fd_; int fd_; ///< The descriptor for the open file
}; };
} // namespace util } // namespace util
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment