[phobos] Fwd: Re: Ruling out arbitrary cost copy construction?
    Robert Jacques 
    sandford at jhu.edu
       
    Mon Nov  1 11:47:55 PDT 2010
    
    
  
On Mon, 01 Nov 2010 14:32:39 -0400, Andrei Alexandrescu  
<andrei at erdani.com> wrote:
> Increment is not atomic on most processors, including x86 (inc  
> [someAddress] does not exist).
>
> Andrei
Umm, inc [address] does exits. However, in order to make it atomic, you're  
supposed to use the lock prefix. I.e.
ref int atomic_inc(ref int value) {
     asm {
         lock;				// Makes this instruction atomic.
         inc [EAX];			 // implicit pointer type
         //inc int ptr [EAX]; // explicit pointer type
     }
}
    
    
More information about the phobos
mailing list