瀏覽代碼

[cpp] Add cpp::AtomicInt type

Hugh 9 年之前
父節點
當前提交
bb3256622d
共有 1 個文件被更改,包括 18 次插入0 次删除
  1. 18 0
      std/cpp/AtomicInt.hx

+ 18 - 0
std/cpp/AtomicInt.hx

@@ -0,0 +1,18 @@
+package cpp;
+
+@:scalar @:coreType
+extern abstract AtomicInt from(Int) to(Int)
+{
+   // returns true if exchange took place
+   @:native("_hx_atomic_exchange_if")
+   public static function exchangeIf(ioValue:Pointer<AtomicInt>, test:Int, newVal:Int) : Bool;
+
+   // returns value before increment
+   @:native("_hx_atomic_inc")
+   public static function atomicInc(ioValue:Pointer<AtomicInt>) : Int;
+
+   // returns value before decrement
+   @:native("_hx_atomic_dec")
+   public static function atomicDec(ioValue:Pointer<AtomicInt>) : Int;
+}
+