[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Object "Forwarding" Between States
- From: "Marc H. Balmer" <marc@...>
- Date: Wed, 29 Jun 2022 09:55:28 +0200
Am 29.06.22 um 09:47 schrieb Oliver:
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:
There is also mqLua, https://github.com/arcapos/mqlua
It does basically the same, but include ZeroMQ for message passing
between Lua states.
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: https://github.com/osch/lua-mtstates#examples