On 7/8/2013 4:04 AM, Tim Blechmann wrote:
hi all,
i've submitted an implementation of semaphores for boost.thread to trac [1]. they provide an interface similar to boost.interprocess semaphores, with the exception of having chrono-style try_wait_for and try_wait_until members for timed_wait.
the patch provides the following implementations: * win32 semaphores (tested with windows 8) * posix semaphores (tested with linux) * dispatch semaphores (tested with osx 10.8) * mutex/condition_variable/counter emulation
the native implementations are much faster than the fallback, in microbenchmarks with high contention, i've seen a speedup of 30 to 80.
would be great if they can be incorporated into boost.thread. comments/suggestions on the API are highly appreciated.
As I understood the reason semaphores were not included in c++11 was because they were too hard to use and the recommendation is to just use condition_variable instead. What is wrong with guidance that would lead us back to wanting to use semaphores?