[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua Lanes with package.preload and package.loader
- From: Benoit Germain <bnt.germain@...>
- Date: Thu, 17 Nov 2011 08:19:26 +0100
2011/11/17 Greg <firstname.lastname@example.org>:
>> 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")
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
> 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