瀏覽代碼

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

Constantine Teplyakov 5 年之前
父節點
當前提交
11860cfeb0
共有 2 個文件被更改,包括 38 次插入0 次删除
  1. 1 0
      extra/CHANGES.txt
  2. 37 0
      std/hl/_std/sys/thread/Lock.hx

+ 1 - 0
extra/CHANGES.txt

@@ -8,6 +8,7 @@
 
 
 	all : fixed EnumValue handling in constant propagation with analyzer enabled (#8959)
 	all : fixed EnumValue handling in constant propagation with analyzer enabled (#8959)
 	all : fixed compiler crash upon Void items in array declarations (#8972)
 	all : fixed compiler crash upon Void items in array declarations (#8972)
+	hl : fixed `sys.thread.Lock` implementation for Hashlink 1.11+ (#8699)
 	js/eval/java/jvm/cs/python/lua : fixed `Std.parseInt()` for hexadecimals with leading whitespaces (#8978)
 	js/eval/java/jvm/cs/python/lua : fixed `Std.parseInt()` for hexadecimals with leading whitespaces (#8978)
 	java/cs : fixed `Reflect.callMethod(o, method, args)` for `args` not containing optional arguments (#8975)
 	java/cs : fixed `Reflect.callMethod(o, method, args)` for `args` not containing optional arguments (#8975)
 	cs : fixed Json.stringify for @:struct-annotated classes (#8979)
 	cs : fixed Json.stringify for @:struct-annotated classes (#8979)

+ 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