ConditionVariable / Monitor as extension to Mutex
Posted: Tue Mar 11, 2014 5:24 pm
Hi there,
I would really appreciate If you could implement a ConditionVariable/Monitor as extension to the already knwon Mutex.
Semaphores might seem similar, but there are a completely different thing. See this lexture notes: Lec09_notes.pdf from Prashant Shenoy.
I have implemented my own ConditionVariable using Semaphores, but there is a problem. Because the Mutexes in PureBasic were acting like ReentrantLocks in Java, you have to count the calls to 'LockMutex()' and corresponding to that you have to call 'UnlockMutex()' for the waiting condition. Then after getting a signal you have to call 'LockMutex()' accordingly one or more times before return from the 'wait' method. This workaround makes programs slow.
It would be nice if PureBasic would implement the Monitor construct in a low level form.
I would really appreciate If you could implement a ConditionVariable/Monitor as extension to the already knwon Mutex.
Semaphores might seem similar, but there are a completely different thing. See this lexture notes: Lec09_notes.pdf from Prashant Shenoy.
I have implemented my own ConditionVariable using Semaphores, but there is a problem. Because the Mutexes in PureBasic were acting like ReentrantLocks in Java, you have to count the calls to 'LockMutex()' and corresponding to that you have to call 'UnlockMutex()' for the waiting condition. Then after getting a signal you have to call 'LockMutex()' accordingly one or more times before return from the 'wait' method. This workaround makes programs slow.
It would be nice if PureBasic would implement the Monitor construct in a low level form.