druntime thread_needLock()

Sean Kelly sean at invisibleduck.org
Sun Dec 7 00:23:01 PST 2008

Fawzi Mohamed wrote:
> On 2008-12-07 03:48:40 +0100, Sean Kelly <sean at invisibleduck.org> said:
>> Not true.  You would need an acquire barrier in thread_needLock. 
>> However, on x86 the point is probably moot since loads have acquire 
>> semantics anyway.
> You would need a very good processor to reorder speculative loads before 
> a function call and a branch. As far as I know even alpha did not do it.

But if thread_needLock() is inlined...

> A volatile statement will probably be enough in all cases, but you are 
> right that to be really correct a load barrier should be done, an even 
> in a processor where this might matter the cost of it in the fast path 
> will be basically 0 (so still better than a lock).

Aye.  I'd do this if there were a common use case that justified it, but 
I don't see one.


More information about the Digitalmars-d mailing list