diff -r e57bfdb4f12c -r caafe12b0378 src/core/model/unix-system-condition.cc --- a/src/core/model/unix-system-condition.cc Sun Dec 07 22:08:04 2014 -0800 +++ b/src/core/model/unix-system-condition.cc Tue Dec 09 13:17:49 2014 -0800 @@ -25,28 +25,66 @@ #include "log.h" +/** + * \file + * \ingroup thread + * Thread conditional wait implementation for Unix-like systems. + */ + namespace ns3 { NS_LOG_COMPONENT_DEFINE ("SystemCondition"); +/** + * \ingroup thread + * Implementation of SystemCondition for Unix-like systems. + */ class SystemConditionPrivate { public: /// Conversion from ns to s. static const uint64_t NS_PER_SEC = (uint64_t)1000000000; + /** Constructor. */ SystemConditionPrivate (); + /** Destructor. */ ~SystemConditionPrivate (); - + + /** + * Set the condition. + * + * \param condition The new condition value. + */ void SetCondition (bool condition); + /** + * Get the condition value. + * + * \returns The condition value. + */ bool GetCondition (void); + /** Signal the condition. */ void Signal (void); + /** Broadcast the condition. */ void Broadcast (void); + /** + * Unset the condition, then wait for another thread + * to set it with SetCondition. */ void Wait (void); + /** + * Unset the condition, then wait for a limited amount of wall-clock + * time for another thread to set it with SetCondition. + * + * \param ns Maximum time to wait, in ns. + * \returns \c true if the condition timed out; \c false if the other + * thread set it. + */ bool TimedWait (uint64_t ns); private: + /** Mutex controlling access to the condition. */ pthread_mutex_t m_mutex; + /** The pthread condition variable. */ pthread_cond_t m_cond; + /** The condition state. */ bool m_condition; };