Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,13 @@ jobs:

- name: Setup Lua
if: matrix.target == 'lua'
# Note: -D lua-vanilla cannot be used here because hxcoro unconditionally requires luv:
# 1. The generated event loop calls luv.run() at startup to drive async tasks.
# 2. Sys.getenv (inside #if sys, which is true for Lua) reads HXCORO_DISPATCHER at
# startup; with -D lua-vanilla, any Sys call throws NotImplementedException.
# Therefore the full luarocks dependency set (luv, lrexlib-pcre2, luautf8, bit32) is needed.
shell: bash
run: |
if [[ "$RUNNER_OS" == "Linux" ]]; then
sudo apt-get install -y lua5.4 lua5.4-dev luarocks libpcre2-dev
sudo apt-get install -y lua5.4
sudo update-alternatives --set lua-interpreter /usr/bin/lua5.4
sudo luarocks --lua-version 5.4 install luv
sudo luarocks --lua-version 5.4 install lrexlib-pcre2
sudo luarocks --lua-version 5.4 install luautf8
sudo luarocks --lua-version 5.4 install bit32
elif [[ "$RUNNER_OS" == "macOS" ]]; then
brew install lua luarocks pcre2
luarocks install luv
luarocks install lrexlib-pcre2
luarocks install luautf8
luarocks install bit32
brew install lua
fi

- name: Setup haxelib
Expand Down
1 change: 1 addition & 0 deletions callstack-tests/build-lua.hxml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build-base.hxml
-D lua-vanilla
--lua bin/test.lua
--cmd lua bin/test.lua
2 changes: 2 additions & 0 deletions src/hxcoro/concurrent/BackOff.hx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class BackOff {
eval.vm.NativeThread.yield();
#elseif jvm
// jvm seems to do best without anything here
#elseif lua_vanilla
// Sys.sleep is not available in -D lua-vanilla; busy-wait without yielding
#elseif sys
Sys.sleep(1 / 0xFFFFFFFFu32);
#else
Expand Down
8 changes: 7 additions & 1 deletion src/hxcoro/schedulers/EventLoopScheduler.hx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,14 @@ class HeapScheduler implements IScheduler {
return event;
}

public function now() {
public function now():Int64 {
#if lua_vanilla
// Timer.stamp() calls Sys.time() which is not available in -D lua-vanilla.
// Use lua.Os.clock() (CPU time, seconds) as a substitute.
return haxe.Int64.ofInt(Std.int(lua.Os.clock() * 1000));
#else
return Timer.milliseconds();
#end
}

}
Expand Down
1 change: 1 addition & 0 deletions tests/build-lua.hxml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build-base.hxml
-D lua-vanilla
--lua bin/coro.lua
--cmd lua bin/coro.lua
4 changes: 2 additions & 2 deletions tests/src/Main.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import hxcoro.run.Setup;

function main() {
#if sys
#if (sys && !lua_vanilla)
switch (Sys.getEnv("HXCORO_DISPATCHER")) {
case "trampoline":
Sys.println("Using trampoline dispatcher");
Expand All @@ -14,7 +14,7 @@ function main() {
case _:
Sys.println("Using default dispatcher");
}
#end
#end // (sys && !lua_vanilla)

final runner = new atest.Runner();

Expand Down
Loading