Compare commits
No commits in common. "606f2cdd57bee39c33e53c17ea1076d26e903213" and "a8f5717b566376a08d48f0b348a2008d0a2c32a0" have entirely different histories.
606f2cdd57
...
a8f5717b56
6
Makefile
6
Makefile
@ -1,4 +1,4 @@
|
|||||||
.PHONY: clean install-mods install build-c
|
.PHONY: clean install-mods install
|
||||||
|
|
||||||
install: clean install-mods
|
install: clean install-mods
|
||||||
luajit build/init.lua --linux
|
luajit build/init.lua --linux
|
||||||
@ -11,7 +11,3 @@ 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
|
|
||||||
|
@ -31,8 +31,8 @@ function arrays.append(self, ...) end
|
|||||||
|
|
||||||
--- Adds all the given elements to the end of this array
|
--- Adds all the given elements to the end of this array
|
||||||
--- @generic T
|
--- @generic T
|
||||||
--- @param self array<T>
|
--- @param self T[]
|
||||||
--- @param ... T
|
--- @param ... T[]
|
||||||
--- @return self
|
--- @return self
|
||||||
function arrays.push(self, ...) end
|
function arrays.push(self, ...) end
|
||||||
|
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
--- @meta promise
|
|
||||||
|
|
||||||
local exports = {};
|
|
||||||
|
|
||||||
--- Adds a message on the event loop to be executed later
|
|
||||||
--- @param ... fun()
|
|
||||||
function exports.push(...) end
|
|
||||||
|
|
||||||
--- Adds the "main" function as a message and starts execution of the event loop (unless it's already running)
|
|
||||||
--- The "main" function is called with the given arguments
|
|
||||||
--- @param main fun(...)
|
|
||||||
function exports.run(main, ...) end
|
|
||||||
|
|
||||||
--- Will suspend the execution of the current message and will continue to the next
|
|
||||||
--- Tip: saving the current thread with "coro.running()" and then transferring back to it works
|
|
||||||
function exports.interrupt() end
|
|
||||||
|
|
||||||
return exports;
|
|
@ -1,3 +0,0 @@
|
|||||||
--- @meta global
|
|
||||||
|
|
||||||
return _G;
|
|
@ -1,5 +1,6 @@
|
|||||||
--- @meta
|
--- @meta
|
||||||
|
|
||||||
|
|
||||||
--- Splits the given string with the given delimiter
|
--- Splits the given string with the given delimiter
|
||||||
--- @param self string
|
--- @param self string
|
||||||
--- @param sep string The delimiter to split by. Defaults to an empty string
|
--- @param sep string The delimiter to split by. Defaults to an empty string
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
box = table.pack;
|
box = table.pack;
|
||||||
unbox = table.unpack;
|
unbox = table.unpack;
|
||||||
exit = os.exit;
|
exit = os.exit;
|
||||||
promise = require "promise";
|
|
||||||
|
|
||||||
--- @param box table
|
--- @param box table
|
||||||
--- @param s? number
|
--- @param s? number
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
local resolver = require "lua-resolver";
|
local resolver = require "lua-resolver";
|
||||||
|
|
||||||
local stack = array {};
|
local stack = array {};
|
||||||
local active_th, main_th;
|
local active;
|
||||||
|
|
||||||
local exports = {};
|
local exports = {};
|
||||||
|
|
||||||
@ -11,24 +11,23 @@ function exports.push(...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function exports.interrupt()
|
function exports.interrupt()
|
||||||
if coro.running() == active_th then
|
if coro.running() == active 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(main_th);
|
return coro.transfer(exports.main);
|
||||||
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_th);
|
return coro.transfer(active);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param main fun(...)
|
--- @param main fun(...)
|
||||||
--- @param ... any
|
--- @param ... any
|
||||||
function exports.run(main, ...)
|
function exports.run(main, ...)
|
||||||
if active_th then
|
if active 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 ()
|
||||||
@ -36,16 +35,16 @@ function exports.run(main, ...)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
while #stack > 0 do
|
while #stack > 0 do
|
||||||
active_th = coro.create(function ()
|
active = coro.create(function ()
|
||||||
while #stack > 0 and coro.running() == active_th do
|
while #stack > 0 and coro.running() == active do
|
||||||
local msg = stack:shift();
|
local msg = stack:shift();
|
||||||
msg();
|
msg();
|
||||||
end
|
end
|
||||||
|
|
||||||
coro.transfer(main_th);
|
coro.transfer(exports.main);
|
||||||
end);
|
end);
|
||||||
|
|
||||||
coro.transfer(active_th);
|
coro.transfer(active);
|
||||||
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:at(i));
|
lines:push(self:sub(1, 1));
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
while true do
|
while true do
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
--- @alias promise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> promiselib | { when: fun(ful: fun(p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7, p8: T8, p9: T9, p10: T10), rej: fun(err)) }
|
--- @alias promise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> promiselib | { when: fun(ful: fun(p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7, p8: T8, p9: T9, p10: T10), rej: fun(err)) }
|
||||||
|
|
||||||
--- @class promiselib
|
--- @class promiselib
|
||||||
local promise = {};
|
promise = {};
|
||||||
promise.__index = promise;
|
promise.__index = promise;
|
||||||
|
|
||||||
--- @generic T1, T2, T3, T4, T5, T6, T7, T8, T9, T10
|
--- @generic T1, T2, T3, T4, T5, T6, T7, T8, T9, T10
|
Loading…
Reference in New Issue
Block a user