Atomically Modify a Table Value
v = atomic.modify(t, idx, mask, inc)
Modifies t[idx]
by applying a bit mask
and increment value inc
.
Returns v
as the original value.
e.g.
atomic.modify(t, 'x', 0, 1)
- increments t.x
atomic.modify(t, 'x', 0, -1)
- decrements t.x
atomic.modify(t, 'y', -1, 123)
- sets t.y
to 123The mask and increment operation in C:
v = (v & ~mask) + inc;