|
Boost : |
From: Bronek Kozicki (brok_at_[hidden])
Date: 2003-04-27 04:15:12
William E. Kempf wrote:
>> Could this not have been implemented with a critical section and use
>> TryEnterCriticalSection? Why was the mutex approach used for one and
>> not the other?
>
> TryEnterCriticalSection is not portable. Specifically, it's not
> available in the Win9x line.
Critical sections in Win32 are much more efficient than mutexes, which
sometimes is important thing in multithreaded programs - especially
those running on servers. It would be nice to use them in compatible
environment ie. WinNT family . There could be some switch like:
#define BOOST_THREAD_WIN32_USE_CRITICAL_SECTION
which will force use of critical section instead of mutex. Of course
program compiled with this switch might not run in Win9x, which is fine.
If anybody wants to use mutex (ie. compile for compatibility with old
environment) , he/she will just not define above mentioned symbol. I
hope this proposal will not introduce maintenance nightmare.
Just my $0.02
B.
PS. I'm first-time writer here, hello all.
PS2. there's old sample of recursive critical section ie. "metered
section" in MSDN, see
http://msdn.microsoft.com/library/en-us/dndllpro/html/msdn_metrsect.asp
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk