[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: how to transfer Lua Function and function params between different Lua state?
- From: Declan White <deco.da.man@...>
- Date: Sun, 25 Nov 2012 15:30:43 +0000 (UTC)
chuang <lichuang1982 <at> gmail.com> writes:
>
>
> I want to write a C module,when Lua call this module's spawn function,it
create a new Lua state,and the new Lua state can call its Lua function,like
this:
>
>
> require("qnode")
>
> function test(a)
> print("in test")
> print(a)
> end
>
> qnode.spawn(test, 100)
>
>
> but,when i review the Lua C API,seems there is no function to get the Lua
function from the Lua stack.
> So,how can I achieve this purpose?
>
>
>
>
Take a look at LuaLanes ( https://github.com/LuaLanes/lanes ); it has a few C
functions to copy from Lua state to another.
(In fact, it may do exactly what you want your module to do: multiple Lua states
in separate threads with simple communication).
There's also my deep copy function, which you can find on lua-users (
http://lua-users.org/wiki/CopyTable ); although it is Lua-only, so you'll have
to find a way to convert it.
Regards,
Declan White.