Documentation for Synchronisation primitives

Former-commit-id: 39f86b2f9cd1f44a6b8e52101458f090183707e4
This commit is contained in:
Gawaboumga
2016-02-21 14:36:03 +01:00
parent 07547bdd9f
commit fd627c671f
6 changed files with 144 additions and 8 deletions

View File

@@ -18,32 +18,84 @@
namespace Nz
{
/*!
* \class Nz::ConditionVariable
* \brief Core class that represents a condition variable
*
* The ConditionVariable class is a synchronization primitive that can be used to block a thread, or multiple threads at the same time, until another thread both modifies a shared variable (the condition), and notifies the ConditionVariable
*/
/*!
* \brief Constructs a ConditionVariable object by default
*/
ConditionVariable::ConditionVariable()
{
m_impl = new ConditionVariableImpl;
}
/*!
* \brief Destructs the object
*/
ConditionVariable::~ConditionVariable()
{
delete m_impl;
}
/*!
* \brief Sends a signal to one thread waiting on the condition
*
* If any threads are waiting on *this, calling Signal unblocks one of the waiting threads
*
* \see SignalAll
*/
void ConditionVariable::Signal()
{
m_impl->Signal();
}
/*!
* \brief Sends a signal to every threads waiting on the condition
*
* Unblocks all threads currently waiting for *this
*
* \see Signal
*/
void ConditionVariable::SignalAll()
{
m_impl->SignalAll();
}
/*!
* \brief Makes the thread wait on the condition
*
* Wait causes the current thread to block until the condition variable is notified or a spurious wakeup occurs
*
* \param mutex Mutex for the condition
*
* \remark Produces a NazaraAssert if mutex is invalid
*/
void ConditionVariable::Wait(Mutex* mutex)
{
NazaraAssert(mutex != nullptr, "Mutex must be valid");
m_impl->Wait(mutex->m_impl);
}
/*!
* \brief Makes the thread wait on the condition for a certain amount of time
*
* Wait causes the current thread to block until the condition variable is notified, a specific time is reached, or a spurious wakeup occurs
*
* \param mutex Mutex for the condition
* \param timeout Time before expiration of the waiting
*
* \remark Produces a NazaraAssert if mutex is invalid
*/
bool ConditionVariable::Wait(Mutex* mutex, UInt32 timeout)
{
NazaraAssert(mutex != nullptr, "Mutex must be valid");