int atomic_increment(int addr, int x) { int val = addr; while (atomicCAS(addr, val, val + x) != val) { val = *addr; } return val + x; }
Please log in to leave a comment.
int atomic_increment(int addr, int x) { int val = addr; while (atomicCAS(addr, val, val + x) != val) { val = *addr; } return val + x; }