|
Krita Source Code Documentation
|
#include <kis_lazy_wait_condition.h>
Public Member Functions | |
| void | endWaiting () |
| void | initWaiting () |
| bool | isSomeoneWaiting () |
| KisLazyWaitCondition () | |
| bool | wait (unsigned long time=ULONG_MAX) |
| void | wakeAll () |
Private Attributes | |
| QWaitCondition | m_condition |
| QMutex | m_mutex |
| volatile int | m_waitCounter |
| int | m_wakeupCounter |
This class is used for catching a particular condition met. We call it "lazy", because the decision about the condition is made by the waiting thread itself. The other thread, "wakingup" one, just points the former one the moments of time when the condition might have been satisfied. This creates some limitations for the condition (see a note in the end of the text).
Usage pattern:
Waiting thread:
KisLazyWaitCondition condition; condition.initWaiting(); // (1) while(!checkSatisfied()) { condition.wait(); } condition.endWaiting(); // (2)
Wakingup thread:
if(checkMightSatisfied()) { condition.wakeAll(); }
If the condition is met and reported, it is guaranteed that all the threads, those are currently running between lines (1) and (2) will be waken up and leave the loop.
NOTE: The condition checkSatisfied() must not change it's state, until all the waiting threads leave the waiting loop. This requirement must be guaranteed by the user of this class
Definition at line 50 of file kis_lazy_wait_condition.h.
|
inline |
Definition at line 53 of file kis_lazy_wait_condition.h.
|
inline |
Definition at line 68 of file kis_lazy_wait_condition.h.
References m_mutex, and m_waitCounter.
|
inline |
Definition at line 59 of file kis_lazy_wait_condition.h.
References m_mutex, m_waitCounter, and m_wakeupCounter.
|
inline |
Definition at line 95 of file kis_lazy_wait_condition.h.
References m_waitCounter.
|
inline |
Definition at line 73 of file kis_lazy_wait_condition.h.
References m_condition, m_mutex, and m_wakeupCounter.
|
inline |
Definition at line 85 of file kis_lazy_wait_condition.h.
References m_condition, m_mutex, m_waitCounter, and m_wakeupCounter.
|
private |
Definition at line 101 of file kis_lazy_wait_condition.h.
|
private |
Definition at line 100 of file kis_lazy_wait_condition.h.
|
private |
Definition at line 102 of file kis_lazy_wait_condition.h.
|
private |
Definition at line 103 of file kis_lazy_wait_condition.h.