import "task/atomic";
Atomic class allows to do atomic operations on shared arrays.
You must not mix different kinds of operations as these can use different mechanisms to achieve the atomicity (native atomic instructions or emulation using small number of mutexes selected semi-randomly based on the native pointer value). You can mix get/set/add/cas operations of the same size.
static function get32(arr: Integer[], idx: Integer): Integer
static function get64(arr: Integer[], idx: Integer): Integer, Integer
static function set32(arr: Integer[], idx: Integer, value: Integer)
static function set64(arr: Integer[], idx: Integer, lo: Integer, hi: Integer)
static function add32(arr: Integer[], idx: Integer, value: Integer): Integer
static function add64(arr: Integer[], idx: Integer, lo: Integer, hi: Integer): Integer, Integer
static function cas32(arr: Integer[], idx: Integer, expected_value: Integer, new_value: Integer): Integer
static function cas64(arr: Integer[], idx: Integer, expected_lo: Integer, expected_hi: Integer, new_lo: Integer, new_hi: Integer): Integer, Integer
static function run(arr: Integer[], idx: Integer, func, data): Dynamic
null
, in that case only the index is used
for the locking and can have any value including the negative numbers). The
function must not do more locking otherwise a dead-lock can occur. Returns
the returned value from the function.