lua-users home
lua-l archive

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


Hello,

I have a C multi-threaded program using Lua as user end scripting language ( https://github.com/destroyedlolo/Selene , I already presented some months back :) ).

My main thread is used also to declare some Lua callbacks needs to be called when an MQTT data arrived. So I keep a reference to this function using classical luaL_ref().

Now, my problem : an MQTT data arrives and is handled by another thread, on which I need to created a dedicated Lua_State for this newly created thread. But how can I retrieve then launch this function in the new lua_state.
Because, for the moment, I'm retrieving the function from the main state, using xmove() it to the new one and this call it ... obviously, it's crashing as the main state may be busy by other tasks.
In addition, I don't want to block the main thread using mutex as I don't want to have to rely on main thead activities.

So any idea welcome :)

Thanks

Laurent