lua-users home
lua-l archive

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

On Sat, 2021-02-27 at 04:28 +0000, caco wrote:
> From C I have master process in parallel with number of agent
> processes each binding a luaL_State. I want the agents Lua scripts to
> communicate through Lua supervised (i.e. gc'd) data. How can I do
> this? 
You can't directly move GCd data from one Lua state to another (do not
use lua_xmove, it will break horribly when moving between different Lua
states). You have to read it from one state's stack into some form and
then recreate it on another one. Trivial fror strings, numbers and
lightuserdata, much harder for tables and full userdata.
I'd suggest to take a look at some existing multithreading libraries
for Lua since they typically include some mechanism of passing data
between states. There are also separate serialization libraries that
you can use in your application.
v <>