lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]




On Mon, Mar 27, 2023 at 11:29 PM Schmalzer, Lukas <Lukas.Schmalzer@trumpf.com> wrote:

Hello,

 

I don’t know if it was ever discussed, that when you call C functions in Lua coroutines, the whole Lua system is blocked, i.e., no coroutine can advance.

Currently there is no way to yield from C. This behavior is problematic for time critical applications, e.g., as in our application, the execution environment for machine sequences.


The current version, 5.4.x, can yield from C and then continue. I typically don't do that, but when I call Lua from C I use lua_callk so the called Lua routine can yield the coroutine. The downside is that you have to provide an explicit continuation function that's called after a yield and resume because the C stack was obliterated, but it's definitely possible to do that. See section 4.5 of the Lua 5.4 reference manual.

Ge'