From 79065dd273c841f92e5d2c4deb3745eb532087d4 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Hayes" Date: Tue, 18 Feb 2020 14:57:47 -0600 Subject: [PATCH 1/4] Haxe4 Sys Platform Support. --- src/tink/concurrent/Mutex.hx | 7 +++++++ src/tink/concurrent/Queue.hx | 9 ++++++++- src/tink/concurrent/Thread.hx | 8 ++++++++ src/tink/concurrent/Tls.hx | 7 +++++++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/tink/concurrent/Mutex.hx b/src/tink/concurrent/Mutex.hx index aa42898..3fa1a5d 100644 --- a/src/tink/concurrent/Mutex.hx +++ b/src/tink/concurrent/Mutex.hx @@ -46,6 +46,13 @@ abstract Mutex(Impl) { static var mutex_acquire = neko.Lib.loadLazy("std","mutex_acquire",1); static var mutex_try = neko.Lib.loadLazy("std","mutex_try",1); } + #elseif (sys && haxe4) + @:forward(acquire, tryAcquire, release) + private abstract Impl(sys.thread.Mutex) { + public function new() { + this = new sys.thread.Mutex(); + } + } #elseif cpp private abstract Impl(Any) { diff --git a/src/tink/concurrent/Queue.hx b/src/tink/concurrent/Queue.hx index a86a10a..e53f41c 100644 --- a/src/tink/concurrent/Queue.hx +++ b/src/tink/concurrent/Queue.hx @@ -34,7 +34,14 @@ abstract Queue(Impl) { static var deque_add = neko.Lib.loadLazy("std","deque_add",2); static var deque_push = neko.Lib.loadLazy("std","deque_push",2); static var deque_pop = neko.Lib.loadLazy("std","deque_pop",2); - } + } + #elseif (sys && haxe4) + @:forward(push, pop, add) + private abstract Impl(sys.thread.Deque) { + public function new() { + this = new sys.thread.Deque(); + } + } #elseif cpp private abstract Impl(Any) { public inline function new() diff --git a/src/tink/concurrent/Thread.hx b/src/tink/concurrent/Thread.hx index d784f58..9fee6a1 100644 --- a/src/tink/concurrent/Thread.hx +++ b/src/tink/concurrent/Thread.hx @@ -36,7 +36,15 @@ abstract Thread(Impl) from Impl { static var thread_create = neko.Lib.load("std", "thread_create", 2); static var thread_current = neko.Lib.load("std", "thread_current", 0); } + #elseif (sys && haxe4) + @:forward(create) + private abstract Impl(sys.thread.Thread) from sys.thread.Thread to sys.thread.Thread { + static public inline function getCurrent():Impl + return sys.thread.Thread.current(); + static public inline function create(f) + return sys.thread.Thread.create(f); + } #elseif java private class Wrapper implements java.lang.Runnable { diff --git a/src/tink/concurrent/Tls.hx b/src/tink/concurrent/Tls.hx index 390e902..eca3034 100644 --- a/src/tink/concurrent/Tls.hx +++ b/src/tink/concurrent/Tls.hx @@ -31,6 +31,13 @@ abstract Tls(Impl) from Impl { static var tls_set = neko.Lib.load("std","tls_set",2); } + #elseif (sys && haxe4) + @:forward(value) + private abstract Tls(sys.thread.Tls) from sys.thread.Tls to sys.thread.Tls { + public function new() { + this = new sys.thread.Tls(); + } + } #elseif cpp private abstract Impl(Int) { static var sFreeSlot = 0; From e6c8c13756e33c99a49bed068137c6cde0d0968d Mon Sep 17 00:00:00 2001 From: "Gabriel A. Hayes" Date: Tue, 18 Feb 2020 15:36:47 -0600 Subject: [PATCH 2/4] Rename Tls to Impl --- src/tink/concurrent/Tls.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tink/concurrent/Tls.hx b/src/tink/concurrent/Tls.hx index eca3034..9f49a2e 100644 --- a/src/tink/concurrent/Tls.hx +++ b/src/tink/concurrent/Tls.hx @@ -33,7 +33,7 @@ abstract Tls(Impl) from Impl { } #elseif (sys && haxe4) @:forward(value) - private abstract Tls(sys.thread.Tls) from sys.thread.Tls to sys.thread.Tls { + private abstract Impl(sys.thread.Impl) from sys.thread.Tls to sys.thread.Tls { public function new() { this = new sys.thread.Tls(); } From 76037db51ecad6cfcef300ff5bfea8fbcb18d96c Mon Sep 17 00:00:00 2001 From: "Gabriel A. Hayes" Date: Tue, 18 Feb 2020 15:44:39 -0600 Subject: [PATCH 3/4] Correct underlying type of Tls.Impl --- src/tink/concurrent/Tls.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tink/concurrent/Tls.hx b/src/tink/concurrent/Tls.hx index 9f49a2e..d231419 100644 --- a/src/tink/concurrent/Tls.hx +++ b/src/tink/concurrent/Tls.hx @@ -33,7 +33,7 @@ abstract Tls(Impl) from Impl { } #elseif (sys && haxe4) @:forward(value) - private abstract Impl(sys.thread.Impl) from sys.thread.Tls to sys.thread.Tls { + private abstract Impl(sys.thread.Tls) from sys.thread.Tls to sys.thread.Tls { public function new() { this = new sys.thread.Tls(); } From e182c6062bbe5f76f86cf1e66c714b3f55f47e02 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Hayes" Date: Tue, 18 Feb 2020 15:52:12 -0600 Subject: [PATCH 4/4] Try to fix Java Tls --- src/tink/concurrent/Tls.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tink/concurrent/Tls.hx b/src/tink/concurrent/Tls.hx index d231419..57eae6c 100644 --- a/src/tink/concurrent/Tls.hx +++ b/src/tink/concurrent/Tls.hx @@ -31,7 +31,7 @@ abstract Tls(Impl) from Impl { static var tls_set = neko.Lib.load("std","tls_set",2); } - #elseif (sys && haxe4) + #elseif (sys && haxe4 && !java) @:forward(value) private abstract Impl(sys.thread.Tls) from sys.thread.Tls to sys.thread.Tls { public function new() {