lua-users home
lua-l archive

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


On Thu, Dec 2, 2010 at 5:08 PM, Benoit Germain <bgermain@ubisoft.fr> wrote:
>> -----Original Message-----
>> From: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org]
>> On Behalf Of Benoit Germain
>> Sent: Thursday, December 02, 2010 5:17 PM
>> To: Lua mailing list
>> Subject: RE: request feature of luajit2 or lanes
>>
>> >   To solve my problem, luajit2 need to support lua_dump or lanes
>> support lanes.gen with lua filenames(without use lua_dump to get
>> entrypoint function).
>>
>> >   Who can do me a favor,Mike or benoit?
>>
>> If the provided "function" is in fact a string, Lanes could probably
>> either "luaL_loadfile" or "luaL_loadstring" it directly in the target
>> Lua VM. This has the advantage that there are no upvalues to be taken
>> care of. I'll have a look at it, just in case it is easy to do.
>
> [BG] Looks like the code part is done. I luaL_loadstring what's given to me. It works as a regular function lane:
>
>
> require "lanes"
>
> local options = {globals = { b = 666 }}
>
> local gen1 = lanes.gen("*", "dofile('fibonacci.lua')")
> local gen2 = lanes.gen(options, "return b")
>
> fibLane = gen1()
> retLane = gen2()
> fibLane:join()
>
> print( retLane[1])
>
> --->
>
> fib(80)
> ... snip ...
> fib(80) = 2.3416728348468e+016
> 2.3416728348468e+016
> 666
> Killed 1 lane(s) at process end.
>
>
> Would this do?
>
>

Does it actually transfer the string to the new lane and compile it
there, though, or is it still trying to compile, dump and transfer the
string behind the scenes anyway?

If possible I would think it would be good to also have an alternative
function that works like load()/lua_load(), i.e. takes a function that
returns chunks of source code... but thinking about it, I'm not sure
that would work with lane generators.

-Duncan