A wrapper for QWaitCondition that has slots for wakeOne and wakeAll. See warning in expanded documentation. More...
#include <globalsearch/slottedwaitcondition.h>
Public Slots | |
void | wakeOneSlot () |
void | wakeAllSlot () |
void | prewaitLock () |
void | postwaitUnlock () |
Public Member Functions | |
SlottedWaitCondition (QObject *parent) | |
virtual | ~SlottedWaitCondition () |
QMutex * | mutex () |
void | wait (unsigned long timeout) |
A wrapper for QWaitCondition that has slots for wakeOne and wakeAll. See warning in expanded documentation.
This class adds a few new functions to QWaitCondition:
SlottedWaitCondition also includes an internal mutex that can be used for create critical sections before and after calls to wait(). Normally an external mutex is used for this, but calls to wait(), prewaitLock(), and postwaitUnlock() use the internal mutex. Calling mutex() will return a pointer to this mutex. Typical usage of this wait condition is:
SlottedWaitCondition slottedWC; ... connect(sender, SIGNAL(somethingThatFreesSlottedWCsResources()), &slottedWC, SLOT(wakeAllSlot())); slottedWC->prewaitLock(); // Do any work that needs to be peformed in a critical section before waiting ... // Check every 250 milliseconds that we still need to be waiting while (someConditionIsTrue) { slottedWC->wait(250); } // Do any work that needs to be done in a critical section after waking ... slottedWC->postwaitUnlock();
Definition at line 74 of file slottedwaitcondition.h.
GlobalSearch::SlottedWaitCondition::SlottedWaitCondition | ( | QObject * | parent | ) |
Constructor.
parent | Parent for QObject. |
Definition at line 20 of file slottedwaitcondition.cpp.
GlobalSearch::SlottedWaitCondition::~SlottedWaitCondition | ( | ) | [virtual] |
Destructor.
Definition at line 27 of file slottedwaitcondition.cpp.
QMutex* GlobalSearch::SlottedWaitCondition::mutex | ( | ) | [inline] |
Definition at line 108 of file slottedwaitcondition.h.
void GlobalSearch::SlottedWaitCondition::postwaitUnlock | ( | ) | [inline, slot] |
Unlock the internal mutex, m_mutex, to end the critical section after calling wait().
Definition at line 159 of file slottedwaitcondition.h.
void GlobalSearch::SlottedWaitCondition::prewaitLock | ( | ) | [inline, slot] |
Lock the internal mutex, m_mutex, to create a critical section before calling wait().
Definition at line 153 of file slottedwaitcondition.h.
void GlobalSearch::SlottedWaitCondition::wait | ( | unsigned long | timeout | ) | [inline] |
Wait until woken up by one of:
timeout | Timeout in milliseconds. After this time, the wait condition will wake itself and continue. |
This function expects the internal mutex, m_mutex, to be locked before prior to using being called. This can be accomplished by calling lock() on mutex() or prewaitLock(). The internal mutex will be locked before returning from this function. The mutex can be unlocked by calling the convenience function postwaitUnlock(). See class description for example usage.
Definition at line 135 of file slottedwaitcondition.h.
void GlobalSearch::SlottedWaitCondition::wakeAllSlot | ( | ) | [inline, slot] |
Slot that calls QWaitCondition::wakeAll()
Definition at line 147 of file slottedwaitcondition.h.
void GlobalSearch::SlottedWaitCondition::wakeOneSlot | ( | ) | [inline, slot] |
Slot that calls QWaitCondition::wakeOne()
Definition at line 142 of file slottedwaitcondition.h.