Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions std/cpp/_std/haxe/atomic/AtomicObject.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package haxe.atomic;

#if doc_gen
@:coreType
abstract AtomicObject<T:{}> {
public function new(value:T):Void;

public function compareExchange(expected:T, replacement:T):T;

public function exchange(value:T):T;

public function load():T;

public function store(value:T):T;
}
#else
#if cppia
extern
#end
abstract AtomicObject<T: {}>(Dynamic) {
#if cppia
public function new(value:T):Void;

public function compareExchange(expected:T, replacement:T):T;

public function exchange(value:T):T;

public function load():T;

public function store(value:T):T;
#else
public #if !scriptable inline #end function new(value:T) {
this = untyped __global__.__hxcpp_atomic_object_create(value);
}

public #if !scriptable inline #end function compareExchange(expected:T, replacement:T):T {
return untyped __global__.__hxcpp_atomic_object_compare_exchange(this, expected, replacement);
}

public #if !scriptable inline #end function exchange(value:T):T {
return untyped __global__.__hxcpp_atomic_object_exchange(this, value);
}

public #if !scriptable inline #end function load():T {
return untyped __global__.__hxcpp_atomic_object_load(this);
}

public #if !scriptable inline #end function store(value:T):T {
return untyped __global__.__hxcpp_atomic_object_store(this, value);
}
#end
}
#end
3 changes: 2 additions & 1 deletion std/cpp/cppia/HostClasses.hx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ class HostClasses {
"List",
"Map",
"String",
"haxe.atomic.AtomicInt"
"haxe.atomic.AtomicInt",
"haxe.atomic.AtomicObject",
];

static function parseClassInfo(externs:Map<String, Bool>, filename:String) {
Expand Down
6 changes: 3 additions & 3 deletions std/haxe/atomic/AtomicObject.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ package haxe.atomic;
#error "This target does not support atomic operations."
#end

#if (js || cpp)
#error "JavaScript and Hxcpp do not support AtomicObject"
#if js
#error "JavaScript does not support AtomicObject"
#end

/**
Atomic object. Use with care, this does not magically make it thread-safe to mutate objects.
Not supported on JavaScript or C++.
Not supported on JavaScript.
**/
@:coreType
abstract AtomicObject<T:{}> {
Expand Down
1 change: 1 addition & 0 deletions tests/unit/compile-cpp.hxml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ compile-each.hxml
--main unit.TestMain
-cpp bin/cpp
-D HXCPP_NO_DEBUG_LINK
-D HXCPP_ALIGN_ALLOC
1 change: 1 addition & 0 deletions tests/unit/compile-cppia-host.hxml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
-D scriptable
-D dll_export=bin/cppia.classes
-D HXCPP_CATCH_SEGV
-D HXCPP_ALIGN_ALLOC
--debug
--dce no
-cpp bin/cppia
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/src/unitstd/haxe/atomic/AtomicObject.unit.hx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if (target.atomics && !(js || cpp))
#if (target.atomics && !js)
var a = new haxe.atomic.AtomicObject("Hey World!");

a.load() == "Hey World!";
Expand Down
Loading