Boost logo

Boost :

From: Amit (contact.lipik_at_[hidden])
Date: 2008-04-11 10:37:43

Anthony Williams <anthony_w.geo <at>> writes:

> The TSS tests all pass for ICL with a VC8 backend (see the regression
> results), so it should be OK (even with the warnings). Yes, if you remove
> tss_pe.cpp, then you're responsible for TSS cleanup.

Hi again,

The tss seems to be working fine with ICL (though performance falls through the
floor if I don't link in their libguide40.dll - but I guess that is an oddity of
their implementation).

I have a couple of question though. They probably belong on the user list, but
since we are discussing the library anyway...

a) Is it safe to instantiate thread_specific_ptr as a function level static
(i.e. are there likely to be race issues just instantiating the object, in case
the first calls of hte function happens to be concurrent?)?
I did look through the code this time, it appears to be safe since the call to
TlsAlloc is wrapped inside call_once - and it seems to work okay. But given the
nature of these things, and my lack of intimate knowledge of SMP, don't know if
this is unsound.

b) Do you think it is worth providing a wrapper around Interlocked* functions?
e.g., I have created the function below for my use, but if POSIX also provides
something like the Interlocked* win32 calls, it could be made platform
independent if boost.thread provided a CompareExchange wrapper.

template<bool yield>
inline void AtomicSetWord(volatile long &flag,
                                long setToVal=true,
                                long waitTillVal=false)
        while (InterlockedCompareExchange(&flag, setToVal, waitTillVal) !=
                if (yield)

d) And finally, what is the deal with yield? My understanding is that it is not
required on pre-emptive multitasking systems (i.e. all modern ones?)? If so,
perhaps the documentation is misleading, since it says:
"Gives up the remainder of the current thread's time slice, to allow other
threads to run."

Thanks yet again

Boost list run by bdawes at, gregod at, cpdaniel at, john at