hxn

AtomicInt

An integer shared by a native library and Haxe. Either side reads and writes it from any thread without a native call.

The cell is four bytes of memory that both this runtime's atomic operations and the library's operate on. A cell created here with new can be passed to a native call, which borrows it for the duration of the call. A cell returned by a library is in the library's memory and is read and written from Haxe directly. The operations are those of haxe.atomic.AtomicInt.

Constructor

function new(?value:Int = 0)

Static methods

function over(pointer:Ref<Int>, keep:Any):AtomicInt

Wraps the cell at pointer. Its memory stays valid as long as keep is referenced.

Properties

var pointer(get, null):Ref<Int>

The pointer a binding passes to a native call that has the cell as a parameter.

var load(default, null):() -> Int
var store(default, null):(value:Int) -> Int

Sets the value and returns the new value.

var add(default, null):(by:Int) -> Int

Adds by and returns the previous value.

var sub(default, null):(by:Int) -> Int

Subtracts by and returns the previous value.

var and(default, null):(bits:Int) -> Int
var or(default, null):(bits:Int) -> Int
var xor(default, null):(bits:Int) -> Int
var exchange(default, null):(value:Int) -> Int

Sets the value and returns the previous value.

var compareExchange(default, null):(expected:Int, replacement:Int) -> Int

Sets the value if it equals expected. Returns the previous value in both cases.