On 18 Sep 2013 at 12:33, Tim Blechmann wrote:
condition_variables have their use, but stating that other synchronization primitives are more error-prone to use is just wrong!
A CAS lock + CV is very straightforward.
semaphores and win32-style events do have a well-defined semantics, which is more suited in many use cases. of course, they can be emulated with cvs, if you don't care about performance
I have a soft spot for win32-style events because I think they fill a certain useful niche where rolling your own implementation is hard to get race condition free and performant under contention. I tried persuading WG14 to adopt one for C11, but they felt it needed to go through the AWG and POSIX, and libc maintainers weren't interested so I got nowhere. A C++11 future is effectively a one shot win32 pulse event object however, while a C++11 shared_future is effectively a one shot win32 event object. I have been known to use them with <int> and me writing 1 to the promise as a quick and dirty event object ... Niall -- Currently unemployed and looking for work. Work Portfolio: http://careers.stackoverflow.com/nialldouglas/