small fixes again
This commit is contained in:
parent
e6eeb41a75
commit
606f2cdd57
6
Makefile
6
Makefile
@ -1,4 +1,4 @@
|
|||||||
.PHONY: clean install-mods install
|
.PHONY: clean install-mods install build-c
|
||||||
|
|
||||||
install: clean install-mods
|
install: clean install-mods
|
||||||
luajit build/init.lua --linux
|
luajit build/init.lua --linux
|
||||||
@ -11,3 +11,7 @@ install-mods: clean
|
|||||||
clean:
|
clean:
|
||||||
rm -rf ~/.local/bin/tal
|
rm -rf ~/.local/bin/tal
|
||||||
rm -rf ~/.local/lib/.tal_mod
|
rm -rf ~/.local/lib/.tal_mod
|
||||||
|
make -C native clean
|
||||||
|
|
||||||
|
build-c:
|
||||||
|
make -C native build
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
local resolver = require "lua-resolver";
|
local resolver = require "lua-resolver";
|
||||||
|
|
||||||
local stack = array {};
|
local stack = array {};
|
||||||
local active;
|
local active_th, main_th;
|
||||||
|
|
||||||
local exports = {};
|
local exports = {};
|
||||||
|
|
||||||
@ -11,23 +11,24 @@ function exports.push(...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function exports.interrupt()
|
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 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)
|
-- 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
|
else
|
||||||
-- We are currently in an abandoned or a non-loop thread. We can calmly transfer to the active thread
|
-- 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
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param main fun(...)
|
--- @param main fun(...)
|
||||||
--- @param ... any
|
--- @param ... any
|
||||||
function exports.run(main, ...)
|
function exports.run(main, ...)
|
||||||
if active then
|
if active_th then
|
||||||
error "Event loop is already running!";
|
error "Event loop is already running!";
|
||||||
end
|
end
|
||||||
exports.main = coro.running();
|
|
||||||
|
main_th = coro.running();
|
||||||
|
|
||||||
local args = box(...);
|
local args = box(...);
|
||||||
exports.push(function ()
|
exports.push(function ()
|
||||||
@ -35,16 +36,16 @@ function exports.run(main, ...)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
while #stack > 0 do
|
while #stack > 0 do
|
||||||
active = coro.create(function ()
|
active_th = coro.create(function ()
|
||||||
while #stack > 0 and coro.running() == active do
|
while #stack > 0 and coro.running() == active_th do
|
||||||
local msg = stack:shift();
|
local msg = stack:shift();
|
||||||
msg();
|
msg();
|
||||||
end
|
end
|
||||||
|
|
||||||
coro.transfer(exports.main);
|
coro.transfer(main_th);
|
||||||
end);
|
end);
|
||||||
|
|
||||||
coro.transfer(active);
|
coro.transfer(active_th);
|
||||||
print "Abandoned thread...";
|
print "Abandoned thread...";
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -9,7 +9,7 @@ return function (glob)
|
|||||||
|
|
||||||
if sep == "" then
|
if sep == "" then
|
||||||
for i = 1, #self do
|
for i = 1, #self do
|
||||||
lines:push(self:sub(1, 1));
|
lines:push(self:at(i));
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
while true do
|
while true do
|
||||||
|
Loading…
Reference in New Issue
Block a user