aboutsummaryrefslogtreecommitdiff
path: root/tests/appendud.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tests/appendud.lua')
-rw-r--r--tests/appendud.lua20
1 files changed, 11 insertions, 9 deletions
diff --git a/tests/appendud.lua b/tests/appendud.lua
index 65d0798..eb1f768 100644
--- a/tests/appendud.lua
+++ b/tests/appendud.lua
@@ -31,28 +31,30 @@ local _ud = {
31 31
32 32
33function appendud(tab, ud) 33function appendud(tab, ud)
34 io.stderr:write "Starting" 34 io.stderr:write "Starting "
35 tab:beginupdate() set_finalizer( function() tab:endupdate() end ) 35 tab:beginupdate() set_finalizer( function() tab:endupdate() end )
36 ud:lock() set_finalizer( function() ud:unlock() end ) 36 ud:lock() set_finalizer( function() ud:unlock() end )
37 for i = 1,#ud do 37 for i = 1,#ud do
38 tab[#tab+1] = ud[i] 38 tab[#tab+1] = ud[i]
39 end 39 end
40 io.stderr:write "Ending" 40 io.stderr:write "Ending "
41 return tab -- need to return 'tab' since we're running in a separate thread 41 return tab -- need to return 'tab' since we're running in a separate thread
42 -- ('tab' is passed over lanes by value, not by reference) 42 -- ('tab' is passed over lanes by value, not by reference)
43end 43end
44 44
45local t,err= lanes.gen( "io", appendud )( _tab, _ud ) -- create & launch a thread 45local t,err= lanes.gen( "base,io", appendud )( _tab, _ud ) -- create & launch a thread
46assert(t) 46assert(t)
47assert(not err) 47assert(not err)
48 48
49-- test 49-- test
50 50-- print("t:join()")
51t:join() -- Need to explicitly wait for the thread, since 'ipairs()' does not 51a,b,c = t[1],t[2],t[3] -- Need to explicitly wait for the thread, since 'ipairs()' does not
52--a,b,c = t:join() -- Need to explicitly wait for the thread, since 'ipairs()' does not
52 -- value the '__index' metamethod (wouldn't it be cool if it did..?) 53 -- value the '__index' metamethod (wouldn't it be cool if it did..?)
53 54
54io.stderr:write(t[1]) 55print(a,b,c)
56-- print("io.stderr:write(t[1])")
57-- io.stderr:write(t[1])
58_ = t[0]
59print(_)
55 60
56for k,v in ipairs(t) do
57 print(k,v)
58end