lua-users home
lua-l archive

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

On 28.06.22 17:14, Scott Morgan wrote:
> I'm thinking about ways to share objects between states, something I've not
> needed to do before, and have come up with a possible technique:
> Q1 : Has anyone ever done this? (Is there already a lib)

you may want to have a look at "mtstates" for invoking Lua interpreter states
from multiple threads:

> A call in L2, e.g. `fwd:foo("test")`, picks up the name of the method, and it's
> arguments, than passes them into L1's state, calling the method on `obj`.
> Results are then returned to L2 as expected, with non-basic Lua types being
> wrapped in their own forwarding objects.

you could easily do this with pure Lua on top of the low level mtstates package,
see the examples at:

Best regards,