forked from LeenkxTeam/LNXSDK
Update
This commit is contained in:
37
Kha/Tools/windows_x64/std/cs/_std/sys/thread/Condition.hx
Normal file
37
Kha/Tools/windows_x64/std/cs/_std/sys/thread/Condition.hx
Normal file
@ -0,0 +1,37 @@
|
||||
package sys.thread;
|
||||
|
||||
import cs.system.threading.Monitor;
|
||||
|
||||
@:coreApi
|
||||
@:access(sys.thread.Mutex)
|
||||
class Condition {
|
||||
final object:cs.system.Object;
|
||||
|
||||
public function new():Void {
|
||||
this.object = new cs.system.Object();
|
||||
}
|
||||
|
||||
public function acquire():Void {
|
||||
Monitor.Enter(object);
|
||||
}
|
||||
|
||||
public function tryAcquire():Bool {
|
||||
return Monitor.TryEnter(object);
|
||||
}
|
||||
|
||||
public function release():Void {
|
||||
Monitor.Exit(object);
|
||||
}
|
||||
|
||||
public function wait():Void {
|
||||
Monitor.Wait(object);
|
||||
}
|
||||
|
||||
public function signal():Void {
|
||||
Monitor.Pulse(object);
|
||||
}
|
||||
|
||||
public function broadcast():Void {
|
||||
Monitor.PulseAll(object);
|
||||
}
|
||||
}
|
||||
22
Kha/Tools/windows_x64/std/cs/_std/sys/thread/Semaphore.hx
Normal file
22
Kha/Tools/windows_x64/std/cs/_std/sys/thread/Semaphore.hx
Normal file
@ -0,0 +1,22 @@
|
||||
package sys.thread;
|
||||
|
||||
@:coreApi
|
||||
class Semaphore {
|
||||
final native:cs.system.threading.Semaphore;
|
||||
|
||||
public function new(value:Int):Void {
|
||||
this.native = new cs.system.threading.Semaphore(value, 0x7FFFFFFF);
|
||||
}
|
||||
|
||||
public function acquire():Void {
|
||||
native.WaitOne();
|
||||
}
|
||||
|
||||
public function tryAcquire(?timeout:Float):Bool {
|
||||
return native.WaitOne(timeout == null ? 0 : Std.int(timeout * 1000));
|
||||
}
|
||||
|
||||
public function release():Void {
|
||||
native.Release();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user