From 606f2cdd57bee39c33e53c17ea1076d26e903213 Mon Sep 17 00:00:00 2001 From: TopchetoEU <36534413+TopchetoEU@users.noreply.github.com> Date: Thu, 6 Feb 2025 18:12:57 +0200 Subject: [PATCH] small fixes again --- Makefile | 6 +++++- mod/core/evn-loop.lua | 21 +++++++++++---------- mod/core/string.lua | 2 +- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 0ba8452..d4e28db 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: clean install-mods install +.PHONY: clean install-mods install build-c install: clean install-mods luajit build/init.lua --linux @@ -11,3 +11,7 @@ install-mods: clean clean: rm -rf ~/.local/bin/tal rm -rf ~/.local/lib/.tal_mod + make -C native clean + +build-c: + make -C native build diff --git a/mod/core/evn-loop.lua b/mod/core/evn-loop.lua index b2de2a6..5b05248 100644 --- a/mod/core/evn-loop.lua +++ b/mod/core/evn-loop.lua @@ -1,7 +1,7 @@ local resolver = require "lua-resolver"; local stack = array {}; -local active; +local active_th, main_th; local exports = {}; @@ -11,23 +11,24 @@ function exports.push(...) end function exports.interrupt() - if coro.running() == active then + if coro.running() == active_th then -- We are trying to interrupt the currently active event loop thread -- We will transfer away from it and "abandon" it (leave it for non-event loop use) - return coro.transfer(exports.main); + return coro.transfer(main_th); else -- We are currently in an abandoned or a non-loop thread. We can calmly transfer to the active thread - return coro.transfer(active); + return coro.transfer(active_th); end end --- @param main fun(...) --- @param ... any function exports.run(main, ...) - if active then + if active_th then error "Event loop is already running!"; end - exports.main = coro.running(); + + main_th = coro.running(); local args = box(...); exports.push(function () @@ -35,16 +36,16 @@ function exports.run(main, ...) end) while #stack > 0 do - active = coro.create(function () - while #stack > 0 and coro.running() == active do + active_th = coro.create(function () + while #stack > 0 and coro.running() == active_th do local msg = stack:shift(); msg(); end - coro.transfer(exports.main); + coro.transfer(main_th); end); - coro.transfer(active); + coro.transfer(active_th); print "Abandoned thread..."; end end diff --git a/mod/core/string.lua b/mod/core/string.lua index 58025dc..5a8fb97 100644 --- a/mod/core/string.lua +++ b/mod/core/string.lua @@ -9,7 +9,7 @@ return function (glob) if sep == "" then for i = 1, #self do - lines:push(self:sub(1, 1)); + lines:push(self:at(i)); end else while true do