lua-users home
lua-l archive

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

Le mer. 26 juil. 2023 à 19:33, actryx <> a écrit :
How do I load the socket module in a lanes thread. I've tried preloading it, like
but none of this works so far. Help appreciated.


Note that the lib string provided to lanes.gen can only specify standard libraries. If you want to pre-require anything else, you have to provide a table like so:
task = lanes.gen("*", {required={"socket"}}, function() ... end)
where "*" means all libs (you need to load "package" to be able to require stuff in the 'required' list).
Here is what I obtain when I try (windows 10 x64):

Lua 5.4.4  Copyright (C) 1994-2022, PUC-Rio
> lanes = require "lanes".configure()
> socket = lanes.require "socket"
> =socket
table: 000002054E67F190
> task = lanes.gen("*", {required={"socket"}}, function(t) print("got: ", t) end)
> task(socket)
Lane: 000002054E72E768
> got:  table: 000002054E70D740

Possibly this is caused by some missing path/cpath in your setup?