Re: [boost] [boost thread rework] New version uploaded to BoostVault

Yes, but it could have been a class static as easily and have the same performance. In general, named mutexes, semaphores, and events in windows are for ipc use and are therefore much more expensive to create than the anonymous versions and critical sections are much quicker than the handle base apis in low contention situations and as quick in high contention ones. At least, that's what my tests have shown. joe
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Peter Dimov Sent: Friday, September 02, 2005 12:36 PM To: boost@lists.boost.org Subject: Re: [boost] [boost thread rework] New version uploaded to BoostVault
Greer, Joe wrote:
-----Original Message----- Running the test program, the semaphore version gives a timing of 16s compiled with gcc-mingw-4.0.1, and 22s compiled with MSVC 7.1, on my machine. The mutex version gives timings of 23s (gcc) and 29s (MSVC), so the semaphore version is clearly faster.
Why use either? I wrote an implantation using critical sections and my timings are:
Semaphores: 20 Mutex: 27 Critical section: 0
I must be missing something vital.
You have a local static that is not thread-safe in general. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Greer, Joe wrote:
Yes, but it could have been a class static as easily and have the same performance.
There is no guarantee that the class static initialization precedes the first call to call_once. Typically one would use call_once in such a scenario to manage the initialization, as this is one of its primary uses. Not possible in this case for obvious reasons. :-)

"Peter Dimov" <pdimov@mmltd.net> writes:
Greer, Joe wrote:
Yes, but it could have been a class static as easily and have the same performance.
There is no guarantee that the class static initialization precedes the first call to call_once.
In case it isn't obvious, I think Peter is saying you still have a thread safety problem that can't be brushed off by saying "it could have been a class static..." -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (3)
-
David Abrahams
-
Greer, Joe
-
Peter Dimov