Boost logo

Boost :

From: Anthony Williams (anthony_w.geo_at_[hidden])
Date: 2007-10-08 02:27:59


John Maddock <john <at> johnmaddock.co.uk> writes:

> Just a couple of quick questions/comments regarding the use of
> _ReadWriteBarrier in the latest Boost.Thread code:
>
> First up _ReadWriteBarrier is a VC++ compiler intrinsic: it's not supported
> by the Borland or MingW compilers, so these fail to link with unresolved
> externals to _ReadWriteBarrier. Can interlocked_read_acquire be written in
> terms of InterlockedCompareExchange(pointer, 0, 0) and
> InterlockedCompareExchangePointer(pointer-to-pointer, 0, 0) in these cases?

Yes, that's top of my list for this morning.
 
> Secondly, I'm a bit confused why the barrier is *after* the read, shouldn't
> it be before? I'm not saying it should be, I just wondered

As Timmo says, it's so nothing can be moved before the read. It's OK to move
stuff into a critical section, but never out.

Anthony


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