lua-users home
lua-l archive

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


2011/11/17 Greg <tghill@hotmail.com>:
>> I the problem is that you go through C to load some native functions.
>> Because of this, Lanes doesn't have knowledge of them, therefore
>> cannot transfer them from one Lua state to another.
>
> I previously got older versions of lanes to work by doing this:
>
>    local p = package.preload["socket.core"]
>
>    local f = lanes.gen("*", function()
>
>        package.preload["socket.core"] = p
>
>        local socket = require("socket")
>    )
>
>    f()

Yes. It works with versions 2.x because it transfer function
references from one lua State to the other by extracting the C
function pointer from the source function, and creating a C closure in
the target state using this pointer. I no longer do this because:
1/ it is not LuaJIT-compatible.
2/ after all, the target state calls a function while not having fully
initialized the module/library the function come from, which is a bad
idea.

>
> Could there be an easy way to do something similar for "lua51-lanes"?


Unless I have done something wrong, lua51-lanes should be
automatically registered in all lane states, so you don't have to do
anything.


-- 
Benoit.