|
Boost : |
Subject: Re: [boost] [thread] semaphore
From: Jonathan Wakely (jwakely.boost_at_[hidden])
Date: 2013-09-18 06:54:12
On 18 September 2013 11:33, Tim Blechmann wrote:
>
> also, checking the condition requires you to acquire a lock, which in
Right, to use a condition_variable you need the CV, a lock and a
condition. If you don't have those three things you're using it wrong,
> many use cases is not necessary. and locks are not free, as they involve
> memory barriers and atomic operations. and how many platforms implement
> PI mutexes?
Don't semaphores involve memory barriers and/or atomics too? POSIX
semaphores do.
(N.B. I'm not disputing that semaphores have less overhead than CVs.)
> condition_variables have their use, but stating that other
> synchronization primitives are more error-prone to use is just wrong!
I didn't state that. I was only commenting on the assertion that the
API is crippled by not detecting spurious wakeups.
The claim that semaphores are error-prone comes from something called
Boost.Threads, whatever that is, but it does at least give references:
http://www.boost.org/doc/libs/1_31_0/libs/thread/doc/faq.html#question10
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk