From ebd9c3c4ec2cfe2f08b4f700dcc5bcb2a8b4b847 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Thu, 16 Nov 2023 17:50:24 +0300 Subject: improved interruption (SIGINT, CTRL+C) support * Just like the original LuaJIT interpreter, this will use a hook to automatically raise an error from Lua code. * Unfortunately, as long as Jit compilation is enabled, this cannot reliably work. Therefore we still set an `interrupted` flag that must be polled from tight loops. * Instead of polling via applause_push_sample() which gave interruption-support only to Stream:play(), we now have a separate checkint() function. * checkint() should be manually added to all tight loops. * Stream:foreach() and everthing based on it is now also supporting interruptions (via checkint()). * This internally works via applause_is_interrupted(). A C function was exposed only because LuaJIT does not support volatile-qualifiers and would optimize away reads to the interrupted-flag. As a side effect, we can also reset the hook. * Flags set in signal handlers should be `volatile`. * Added likely() and unlikely() macros to C code. * Updated sample.ipynb Jupyter notebook: Everything important is now supported, albeit requiring custom ILua patches. --- TODO | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'TODO') diff --git a/TODO b/TODO index b1a5e62..294dc27 100644 --- a/TODO +++ b/TODO @@ -1,13 +1,14 @@ # Bugs -* Stream:foreach() cannot be interrupted - Perhaps C core should export an interrupted variable that we can check from Lua. - For Stream:play() this is solved differently. * The MIDIStream should be flushed when starting via Stream:play(). * There are lots of limitations with Jupyter servers (see README). Perhaps it would be better to use xeus-lua, but that would require us to refactor everything - into a proper Lua library. + into a proper Lua library and it's harder to build. https://github.com/jupyter-xeus/xeus-lua +* CTRL+C interruption on the REPL loop does not always work. + Test case: while true do end + This is a known bug in LuaJIT, see https://luajit.org/faq.html#ctrlc. + As a workaround, add checkint() to all tight loops. # Features @@ -30,6 +31,8 @@ or with a Stream:savenow() shortcut. * Multi-core support via GStreamer-like queue: https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer-plugins/html/gstreamer-plugins-queue.html + * If it turns out, we cannot cleanly fork() after starting the Jack client, + it might be possible to send Streams as byte code dumps as well. * Stream optimizer * Automatic caching (finding identical subtrees). * Removing contraproductive caching, e.g. after plain number streams, MIDIStream, EvdevStream... -- cgit v1.2.3