Semaphore.hx 712 B

1234567891011121314151617181920212223242526272829303132
  1. package sys.thread;
  2. #if doc_gen
  3. @:coreApi extern class Semaphore {
  4. function new(value:Int):Void;
  5. function acquire():Void;
  6. function tryAcquire(?timeout:Float):Bool;
  7. function release():Void;
  8. }
  9. #else
  10. abstract Semaphore(hl.Abstract<"hl_semaphore">) {
  11. public function new(value:Int):Void {
  12. this = alloc(value);
  13. }
  14. @:hlNative("std", "semaphore_acquire")
  15. public function acquire():Void {}
  16. @:hlNative("std", "semaphore_release")
  17. public function release():Void {}
  18. @:hlNative("std", "semaphore_try_acquire")
  19. public function tryAcquire(?timeout:Float):Bool {
  20. return false;
  21. }
  22. @:hlNative("std", "semaphore_alloc")
  23. static function alloc(value:Int):hl.Abstract<"hl_semaphore"> {
  24. return null;
  25. }
  26. }
  27. #end