From 1bfdae666c929c7b94141db492cd759b15b28751 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Sun, 16 Aug 2026 19:49:11 +0100 Subject: [PATCH 1/3] [neko] Implement semaphore using lock primitives --- std/neko/_std/sys/thread/Semaphore.hx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/std/neko/_std/sys/thread/Semaphore.hx b/std/neko/_std/sys/thread/Semaphore.hx index de8b10adcbe..91a08d80432 100644 --- a/std/neko/_std/sys/thread/Semaphore.hx +++ b/std/neko/_std/sys/thread/Semaphore.hx @@ -4,23 +4,22 @@ package sys.thread; var s:Dynamic; public function new(value:Int):Void { - s = semaphore_create(value); + s = lock_create(value); } public function acquire():Void { - semaphore_acquire(s); + lock_wait(s); } public function tryAcquire(?timeout:Float):Bool { - return semaphore_try_acquire(s, timeout); + return lock_wait(s, timeout); } public function release():Void { - semaphore_release(s); + lock_release(s); } - static var semaphore_create = neko.Lib.loadLazy("std", "semaphore_create", 1); - static var semaphore_try_acquire = neko.Lib.loadLazy("std", "semaphore_try_acquire", 2); - static var semaphore_acquire = neko.Lib.loadLazy("std", "semaphore_acquire", 1); - static var semaphore_release = neko.Lib.loadLazy("std", "semaphore_release", 1); + static var lock_create = neko.Lib.loadLazy("std", "lock_create", 1); + static var lock_release = neko.Lib.load("std", "lock_release", 1); + static var lock_wait = neko.Lib.load("std", "lock_wait", 2); } From 48e986c1b776b2816b4d39aa5db2fce67a920f13 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Tue, 18 Aug 2026 09:09:20 +0100 Subject: [PATCH 2/3] [neko] Fix semaphore tryAcquire without timeout --- std/neko/_std/sys/thread/Semaphore.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/neko/_std/sys/thread/Semaphore.hx b/std/neko/_std/sys/thread/Semaphore.hx index 91a08d80432..01dbe5d5bd4 100644 --- a/std/neko/_std/sys/thread/Semaphore.hx +++ b/std/neko/_std/sys/thread/Semaphore.hx @@ -12,7 +12,7 @@ package sys.thread; } public function tryAcquire(?timeout:Float):Bool { - return lock_wait(s, timeout); + return lock_wait(s, timeout ?? 0.); } public function release():Void { From 92cf9c4364f3ed5ab0a7cbae50397a0d598aa796 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Tue, 18 Aug 2026 09:22:10 +0100 Subject: [PATCH 3/3] [neko] Fix typing error in Semaphore --- std/neko/_std/sys/thread/Semaphore.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/neko/_std/sys/thread/Semaphore.hx b/std/neko/_std/sys/thread/Semaphore.hx index 01dbe5d5bd4..36ea425b9bd 100644 --- a/std/neko/_std/sys/thread/Semaphore.hx +++ b/std/neko/_std/sys/thread/Semaphore.hx @@ -21,5 +21,5 @@ package sys.thread; static var lock_create = neko.Lib.loadLazy("std", "lock_create", 1); static var lock_release = neko.Lib.load("std", "lock_release", 1); - static var lock_wait = neko.Lib.load("std", "lock_wait", 2); + static var lock_wait:(Dynamic, ?Float) -> Bool = neko.Lib.load("std", "lock_wait", 2); }