Reputation: 3736
We are running an c library that is tested trough a Lua testscript. This runs fine, but we decided that it was time for some multithreading. So we started implementing Lua Lanes but got stuck on loading the C lib for the threads.
So we have a function test, this is the actual test suite function (it runs all other functions) and as a start I tried to push it to a seperate thread, by calling it like this:
local pwlog = require "pwlog"
--A milion lines of code, one of which is the test function
testF = lanes.gen("*", {required = {"pwlog"}}, tests)()
Just to be clear: local pwlog
is not defined in a function, but globally.
I based this on this: https://github.com/LuaLanes/lanes/issues/108, but I found it hard to figure out exactly what he ment. Well, this was wrong:
lua: /usr/local/share/lua/5.1/lanes.lua:327: main: function 'pwlogs/block_size' not found in Lane #0x2390770 destination transfer database
Allright, so I tried something different. I added one additional line to the top of my test function:
local function tests ()
pwlog = require "pwlog"
print("test")
--etc
And I changed the invocation:
testF = lanes.gen("*", tests)()
I thought this would work. Here pwlog does not exist until after the thread is already created, so I figured everything would be ok. But it came back with a very puzzeling error:
lua: /usr/local/share/lua/5.1/lanes.lua:327: can't copy non-deep full userdata across lanes
This error is thrown in the following line:
testF = lanes.gen("*", tests)()
So now I am stuck. How am I supposed to load the C functions into my lua lanes thread?
I am using Lua 5.1
Upvotes: 3
Views: 584