Generic counting semaphore for thread synchronization. More...
Public Member Functions | |
| D_CORE_API | ndSemaphore () |
| Create and initialize counter to zero. | |
| D_CORE_API | ~ndSemaphore () |
| Destroy semaphore. | |
| D_CORE_API ndInt32 | GetCount () const |
| Returns counter counter value. | |
| D_CORE_API bool | Wait () |
| Synchronize with another threads. More... | |
| D_CORE_API void | Signal () |
| Notify a thread blocked by member function Wait to wake and test m_counter again. More... | |
| D_CORE_API void | Terminate () |
| Notify a waiting thread on member function Wait that is time to exit the thread loop. | |
Generic counting semaphore for thread synchronization.
| void ndSemaphore::Signal | ( | ) |
Notify a thread blocked by member function Wait to wake and test m_counter again.
Increment internal variable m_count by one and signal the thread to wakeup.
| bool ndSemaphore::Wait | ( | ) |
Synchronize with another threads.
When internal variable m_counter is zero, this function blocks the calling thread until another thread call Signal function incrementing m_count by one.
when counter is hight that zero, this function return immediately decrementing the m_count by one.