blob: 705b85ebe19a78485f303793c967759f18a39e2e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
--
-- Bugs filed by irayo Jul-2008
--
--[[
"Another issue I've noticed is trying to pass a table with a function
that uses closures in it as a global variable into a new lane. This
causes a segmentation fault and it appears to be related to the
luaG_inter_move function near line 835-836 or so in lanes.c, but I
haven't investigated further.
e.g. { globals = { data = 1, func = function() useclosurehere() end } }"
]]
local lanes = require "lanes"
local function testrun()
assert( print )
assert( data==1 )
assert( type(func)=="function" )
func() -- "using the closure"
return true
end
-- When some function dereferences a global key, the associated global in the source state
-- isn't sent over the target lane
-- therefore, the necessary functions must either be pulled as upvalues (hence locals)
-- or the globals must exist in the target lanes because the modules have been required there
--
local print=print
local assert=assert
local function useclosurehere()
assert( print )
print "using the closure"
end
local lane= lanes.gen( "", { name = 'auto', globals = { data=1, func=useclosurehere } }, testrun )()
print(lane[1])
|