浏览代码

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

Constantine Teplyakov 5 年之前
父节点
当前提交
140842a4d6
共有 1 个文件被更改,包括 37 次插入0 次删除
  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;
 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
 @:coreApi
 class Lock {
 class Lock {
 	var deque:sys.thread.Deque<Bool>;
 	var deque:sys.thread.Deque<Bool>;
@@ -48,3 +83,5 @@ class Lock {
 		deque.push(true);
 		deque.push(true);
 	}
 	}
 }
 }
+
+#end