forked from LeenkxTeam/LNXSDK
Update
This commit is contained in:
55
Kha/Tools/windows_x64/std/haxe/atomic/AtomicBool.hx
Normal file
55
Kha/Tools/windows_x64/std/haxe/atomic/AtomicBool.hx
Normal file
@ -0,0 +1,55 @@
|
||||
package haxe.atomic;
|
||||
|
||||
#if !(target.atomics || core_api)
|
||||
#error "Atomic operations are not supported on this target!"
|
||||
#end
|
||||
|
||||
/**
|
||||
Atomic boolean.
|
||||
(js) The Atomics and SharedArrayBuffer objects need to be available. Errors will be thrown if this is not the case.
|
||||
**/
|
||||
@:coreApi
|
||||
abstract AtomicBool(AtomicInt) {
|
||||
private inline function toInt(v:Bool):Int {
|
||||
return v ? 1 : 0;
|
||||
}
|
||||
|
||||
private inline function toBool(v:Int):Bool {
|
||||
return v == 1;
|
||||
}
|
||||
|
||||
public inline function new(value:Bool):Void {
|
||||
this = new AtomicInt(toInt(value));
|
||||
}
|
||||
|
||||
/**
|
||||
Atomically compares the value of `a` with `expected` and replaces `a` with `replacement` if they are equal..
|
||||
Returns the original value of `a`.
|
||||
**/
|
||||
public inline function compareExchange(expected:Bool, replacement:Bool):Bool {
|
||||
return toBool(this.compareExchange(toInt(expected), toInt(replacement)));
|
||||
}
|
||||
|
||||
/**
|
||||
Atomically exchanges `a` with `value`.
|
||||
Returns the original value of `a`.
|
||||
**/
|
||||
public inline function exchange(value:Bool):Bool {
|
||||
return toBool(this.exchange(toInt(value)));
|
||||
}
|
||||
|
||||
/**
|
||||
Atomically fetches the value of `a`.
|
||||
**/
|
||||
public inline function load():Bool {
|
||||
return toBool(this.load());
|
||||
}
|
||||
|
||||
/**
|
||||
Atomically stores `value` into `a`.
|
||||
Returns the value that has been stored.
|
||||
**/
|
||||
public inline function store(value:Bool):Bool {
|
||||
return toBool(this.store(toInt(value)));
|
||||
}
|
||||
}
|
||||
67
Kha/Tools/windows_x64/std/haxe/atomic/AtomicInt.hx
Normal file
67
Kha/Tools/windows_x64/std/haxe/atomic/AtomicInt.hx
Normal file
@ -0,0 +1,67 @@
|
||||
package haxe.atomic;
|
||||
|
||||
#if !(target.atomics || core_api)
|
||||
#error "This target does not support atomic operations."
|
||||
#end
|
||||
|
||||
/**
|
||||
Atomic integer.
|
||||
(js) The Atomics and SharedArrayBuffer objects need to be available. Errors will be thrown if this is not the case.
|
||||
**/
|
||||
@:coreType
|
||||
abstract AtomicInt {
|
||||
public function new(value:Int):Void;
|
||||
|
||||
/**
|
||||
Atomically adds `b` to `a`.
|
||||
Returns the original value of `a`.
|
||||
**/
|
||||
public function add(b:Int):Int;
|
||||
|
||||
/**
|
||||
Atomically substracts `b` from `a`.
|
||||
Returns the original value of `a`.
|
||||
**/
|
||||
public function sub(b:Int):Int;
|
||||
|
||||
/**
|
||||
Atomically computes the bitwise and of `a` and `b` and stores it in `a`.
|
||||
Returns the original value of `a`.
|
||||
**/
|
||||
public function and(b:Int):Int;
|
||||
|
||||
/**
|
||||
Atomically computes the bitwise or of `a` and `b` and stores it in `a`.
|
||||
Returns the original value of `a`.
|
||||
**/
|
||||
public function or(b:Int):Int;
|
||||
|
||||
/**
|
||||
Atomically computes the bitwise xor of `a` and `b` and stores it in `a`.
|
||||
Returns the original value of `a`.
|
||||
**/
|
||||
public function xor(b:Int):Int;
|
||||
|
||||
/**
|
||||
Atomically compares the value of `a` with `expected` and replaces `a` with `replacement` if they are equal..
|
||||
Returns the original value of `a`.
|
||||
**/
|
||||
public function compareExchange(expected:Int, replacement:Int):Int;
|
||||
|
||||
/**
|
||||
Atomically exchanges `a` with `value`.
|
||||
Returns the original value of `a`.
|
||||
**/
|
||||
public function exchange(value:Int):Int;
|
||||
|
||||
/**
|
||||
Atomically fetches the value of `a`.
|
||||
**/
|
||||
public function load():Int;
|
||||
|
||||
/**
|
||||
Atomically stores `value` into `a`.
|
||||
Returns the value that has been stored.
|
||||
**/
|
||||
public function store(value:Int):Int;
|
||||
}
|
||||
44
Kha/Tools/windows_x64/std/haxe/atomic/AtomicObject.hx
Normal file
44
Kha/Tools/windows_x64/std/haxe/atomic/AtomicObject.hx
Normal file
@ -0,0 +1,44 @@
|
||||
package haxe.atomic;
|
||||
|
||||
#if !(target.atomics || core_api)
|
||||
#error "This target does not support atomic operations."
|
||||
#end
|
||||
|
||||
#if (js || hxcpp)
|
||||
#error "JavaScript and Hxcpp do 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++.
|
||||
**/
|
||||
@:coreType
|
||||
abstract AtomicObject<T:{}> {
|
||||
public function new(value:T):Void;
|
||||
|
||||
/**
|
||||
Atomically compares the value of `a` with `expected` and replaces `a` with `replacement` if they are equal..
|
||||
Returns the original value of `a`.
|
||||
|
||||
Note that comparison is done by reference, and not by value.
|
||||
While this is expected for most objects, this might give unexpected behaviour for strings.
|
||||
**/
|
||||
public function compareExchange(expected:T, replacement:T):T;
|
||||
|
||||
/**
|
||||
Atomically exchanges `a` with `value`.
|
||||
Returns the original value of `a`.
|
||||
**/
|
||||
public function exchange(value:T):T;
|
||||
|
||||
/**
|
||||
Atomically fetches the value of `a`.
|
||||
**/
|
||||
public function load():T;
|
||||
|
||||
/**
|
||||
Atomically stores `value` into `a`.
|
||||
Returns the value that has been stored.
|
||||
**/
|
||||
public function store(value:T):T;
|
||||
}
|
||||
Reference in New Issue
Block a user