lua-users home
lua-l archive

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

why not use lanes?: It is already done and controls thread creation and thread intercomunication.
----- Original Message -----
Sent: Wednesday, April 20, 2016 11:33 AM
Subject: Lua callback in another thread


I have a C multi-threaded program using Lua as user end scripting language ( , 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 :)