lua-users home
lua-l archive

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


Am Mi., 5. Apr. 2023 um 06:57 Uhr schrieb Schmalzer, Lukas
<Lukas.Schmalzer@trumpf.com>:
>
> What we are suggesting is a yield function in C that works same as the familiar yield in Lua: When you call resume, the coroutine continuous after the yield call.
>
This should be exactly what lua_yieldk does. (at least in my software
it works like this without problem ... just condition is, that you
invoke lua_yieldk ONLY in a valid thread / resumed thread (NOT
directly from the Lua state - so you can use lua_yieldk nicely, if a
Lua user in the Lua code wants to specify a "Lua coded" command
string. But you can NOT use lua_yieldk, if you get such a "Lua coded"
command string from "somewhere else").

> I also implemented the Fibonacci sequence in Lua, as you can see the Lua function and the C function of Example fibFiber can be implemented in the same way.

Sorry, this is a bit away from my application. Could you perhaps try a
more simple example, which really has VERY few C code lines to
demonstrate your problem (e. g. use a very simple sleep functionality
or somehting like this).