
Alexander Terekhov <terekhov@web.de> writes:
Anthony Williams wrote: [...]
once.hpp uses a Semaphore, whereas once_mutex.hpp uses a mutex, the same as the existing boost::thread implementation.
IIRC boost::thread implementation optimizes fast path (get rid of kernel calls) and only briefly holds the named lock.
Your stuff looks different in this respect. Is this intentional?
No. Thanks for spotting it; optimizing the mutex implementation makes the overall timings ~100 times faster in my tests. I have attached a simple optimised implementation. I am not sure if I can optimize the Semaphore method, since it relies on the Semaphore itself storing the initialized/not flag. I guess that rules it out, then. Anthony -- Anthony Williams Software Developer