On Mon, 01 Nov 2010 14:32:39 -0400, Andrei Alexandrescu <[email protected]> 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
    }
}


_______________________________________________
phobos mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/phobos

Reply via email to