Browse Source

Update hl._std.sys.thread.Lock (#8744)

Constantine Teplyakov 5 years ago
parent
commit
140842a4d6
1 changed files with 37 additions and 0 deletions
  1. 37 0
      std/hl/_std/sys/thread/Lock.hx

+ 37 - 0
std/hl/_std/sys/thread/Lock.hx

@@ -22,6 +22,41 @@
 
 package sys.thread;
 
+
+#if (hl_ver >= version("1.11.0"))
+
+typedef LockHandle = hl.Abstract<"hl_lock">;
+
+@:coreApi
+@:hlNative("std")
+class Lock {
+	var handle : LockHandle;
+
+	public function new() {
+		handle = lock_create();
+	}
+
+	public function wait( ?timeout : Float ) : Bool {
+		return lock_wait(handle, timeout);
+	}
+
+	public function release( ) : Void {
+		lock_release(handle);
+	}
+
+	static function lock_wait( handle : LockHandle, ?timeout : Float ) : Bool {
+		return false;
+	}
+
+	static function lock_release( handle : LockHandle ) : Void { }
+
+	static function lock_create( ) : LockHandle {
+		return null;
+	}
+}
+
+#else
+
 @:coreApi
 class Lock {
 	var deque:sys.thread.Deque<Bool>;
@@ -48,3 +83,5 @@ class Lock {
 		deque.push(true);
 	}
 }
+
+#end