Boost logo

Boost :

From: Anson Tsao (ansont_at_[hidden])
Date: 2001-10-24 14:00:49


I have a few observations about the Win32 implementation of the thread
library, I'm not sure if they've been covered in previous posts before.

1) In the various lock implementations, casting HANDLE to unsigned long
is not portable to IA64, HANDLE is the same size as pointers. Should
probably cast to void* instead.
2) WaitForSingleObject return values that are not WAIT_OBJECT_0 are
asserted in a number of places. They are runtime conditions that can
return WAIT_ABANDONED, should probably throw an exception instead.
3) Thread specific pointer implementation, it's pretty easy to run out
of TLS slots in NT4, and Win9x OS's, perhaps implementing it with a data
structure using only one TLS slot is safer.

Extending the thread object interface:
1) Creating the thread with attributes: stack size, priority are
portable between Win32 and POSIX, perhaps an optional opaque type for
platform specific attributes

Other thoughts:
1) Since the mutex class is only for process local use, using critical
section with a spin count instead of a real mutex will give you better
performance in general, but especially on multi-processor systems.
InitializeCriticalSectionAndSpinCount is only unavailable in Win95, and
NT4 pre SP3 systems.
2) Portable thread traits class with atomic increments and decrements
functions might be very useful

Anson Tsao

 


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk