diff options
Diffstat (limited to '')
45 files changed, 82 insertions, 80 deletions
diff --git a/deep_userdata_example/deeptest.lua b/deep_userdata_example/deeptest.lua index 6ef4b74..37136cd 100644 --- a/deep_userdata_example/deeptest.lua +++ b/deep_userdata_example/deeptest.lua | |||
@@ -82,6 +82,7 @@ local performTest = function( obj_) | |||
82 | local g = lanes.gen( | 82 | local g = lanes.gen( |
83 | "package" | 83 | "package" |
84 | , { | 84 | , { |
85 | name = 'auto', | ||
85 | required = { "deep_userdata_example"} -- we will transfer userdata created by this module, so we need to make this lane aware of it | 86 | required = { "deep_userdata_example"} -- we will transfer userdata created by this module, so we need to make this lane aware of it |
86 | } | 87 | } |
87 | , function( arg_, t_) | 88 | , function( arg_, t_) |
diff --git a/tests/appendud.lua b/tests/appendud.lua index f510c8b..f6f99c1 100644 --- a/tests/appendud.lua +++ b/tests/appendud.lua | |||
@@ -42,7 +42,7 @@ function appendud(tab, ud) | |||
42 | -- ('tab' is passed over lanes by value, not by reference) | 42 | -- ('tab' is passed over lanes by value, not by reference) |
43 | end | 43 | end |
44 | 44 | ||
45 | local t,err= lanes.gen( "base,io", appendud )( _tab, _ud ) -- create & launch a thread | 45 | local t,err= lanes.gen( "base,io", { name = 'auto'}, appendud )( _tab, _ud ) -- create & launch a thread |
46 | assert(t) | 46 | assert(t) |
47 | assert(not err) | 47 | assert(not err) |
48 | 48 | ||
diff --git a/tests/atexit.lua b/tests/atexit.lua index 9fc3070..ba10d3b 100644 --- a/tests/atexit.lua +++ b/tests/atexit.lua | |||
@@ -16,8 +16,8 @@ local g = function() | |||
16 | print "User cancellation detected!" | 16 | print "User cancellation detected!" |
17 | end | 17 | end |
18 | 18 | ||
19 | local genF = lanes.gen( "", {globals = {threadName = "mylane"}}, f) | 19 | local genF = lanes.gen( "", {name = 'auto', globals = {threadName = "mylane"}}, f) |
20 | local genG = lanes.gen( "", g) | 20 | local genG = lanes.gen( "", { name = 'auto'}, g) |
21 | 21 | ||
22 | 22 | ||
23 | -- launch a good batch of free running lanes | 23 | -- launch a good batch of free running lanes |
diff --git a/tests/basic.lua b/tests/basic.lua index 820d3c8..068dc25 100644 --- a/tests/basic.lua +++ b/tests/basic.lua | |||
@@ -15,7 +15,7 @@ local lanes = require_lanes_result_1 | |||
15 | local require_assert_result_1, require_assert_result_2 = require "assert" -- assert.fails() | 15 | local require_assert_result_1, require_assert_result_2 = require "assert" -- assert.fails() |
16 | print("require_assert_result:", require_assert_result_1, require_assert_result_2) | 16 | print("require_assert_result:", require_assert_result_1, require_assert_result_2) |
17 | 17 | ||
18 | local lanes_gen= assert(lanes.gen) | 18 | local lanes_gen assert(lanes.gen) |
19 | local lanes_linda = assert(lanes.linda) | 19 | local lanes_linda = assert(lanes.linda) |
20 | 20 | ||
21 | local tostring= assert(tostring) | 21 | local tostring= assert(tostring) |
@@ -86,7 +86,7 @@ local function task(a, b, c) | |||
86 | return v, hey | 86 | return v, hey |
87 | end | 87 | end |
88 | 88 | ||
89 | local task_launch= lanes_gen("", { globals={hey=true}, gc_cb = gc_cb}, task) | 89 | local task_launch= lanes.gen("", { name = 'auto', globals={hey=true}, gc_cb = gc_cb }, task) |
90 | -- base stdlibs, normal priority | 90 | -- base stdlibs, normal priority |
91 | 91 | ||
92 | -- 'task_launch' is a factory of multithreaded tasks, we can launch several: | 92 | -- 'task_launch' is a factory of multithreaded tasks, we can launch several: |
@@ -126,7 +126,7 @@ collectgarbage() | |||
126 | 126 | ||
127 | PRINT("\n\n", "---=== Tasking (cancelling) ===---", "\n\n") | 127 | PRINT("\n\n", "---=== Tasking (cancelling) ===---", "\n\n") |
128 | 128 | ||
129 | local task_launch2= lanes_gen("", { globals={hey=true}, gc_cb = gc_cb}, task) | 129 | local task_launch2= lanes.gen("", { name = 'auto', globals={hey=true}, gc_cb = gc_cb }, task) |
130 | 130 | ||
131 | local N=999999999 | 131 | local N=999999999 |
132 | local lane9= task_launch2(1,N,1) -- huuuuuuge... | 132 | local lane9= task_launch2(1,N,1) -- huuuuuuge... |
@@ -177,7 +177,7 @@ local wait_send = function() | |||
177 | a,b = limited:send("key", "bybye") -- infinite timeout, returns only when lane is cancelled | 177 | a,b = limited:send("key", "bybye") -- infinite timeout, returns only when lane is cancelled |
178 | end | 178 | end |
179 | 179 | ||
180 | local wait_send_lane = lanes.gen("*", wait_send)() | 180 | local wait_send_lane = lanes.gen("*", { name = 'auto' }, wait_send)() |
181 | repeat until wait_send_lane.status == "waiting" | 181 | repeat until wait_send_lane.status == "waiting" |
182 | print "wait_send_lane is waiting" | 182 | print "wait_send_lane is waiting" |
183 | wait_send_lane:cancel() -- hard cancel, 0 timeout | 183 | wait_send_lane:cancel() -- hard cancel, 0 timeout |
@@ -190,7 +190,7 @@ local wait_receive = function() | |||
190 | k, v = limited:receive("dummy") -- infinite timeout, returns only when lane is cancelled | 190 | k, v = limited:receive("dummy") -- infinite timeout, returns only when lane is cancelled |
191 | end | 191 | end |
192 | 192 | ||
193 | local wait_receive_lane = lanes.gen("*", wait_receive)() | 193 | local wait_receive_lane = lanes.gen("*", { name = 'auto' }, wait_receive)() |
194 | repeat until wait_receive_lane.status == "waiting" | 194 | repeat until wait_receive_lane.status == "waiting" |
195 | print "wait_receive_lane is waiting" | 195 | print "wait_receive_lane is waiting" |
196 | wait_receive_lane:cancel() -- hard cancel, 0 timeout | 196 | wait_receive_lane:cancel() -- hard cancel, 0 timeout |
@@ -203,7 +203,7 @@ local wait_receive_batched = function() | |||
203 | k, v1, v2 = limited:receive(limited.batched, "dummy", 2) -- infinite timeout, returns only when lane is cancelled | 203 | k, v1, v2 = limited:receive(limited.batched, "dummy", 2) -- infinite timeout, returns only when lane is cancelled |
204 | end | 204 | end |
205 | 205 | ||
206 | local wait_receive_batched_lane = lanes.gen("*", wait_receive_batched)() | 206 | local wait_receive_batched_lane = lanes.gen("*", { name = 'auto' }, wait_receive_batched)() |
207 | repeat until wait_receive_batched_lane.status == "waiting" | 207 | repeat until wait_receive_batched_lane.status == "waiting" |
208 | print "wait_receive_batched_lane is waiting" | 208 | print "wait_receive_batched_lane is waiting" |
209 | wait_receive_batched_lane:cancel() -- hard cancel, 0 timeout | 209 | wait_receive_batched_lane:cancel() -- hard cancel, 0 timeout |
@@ -275,7 +275,7 @@ local function PEEK(...) return linda:get("<-", ...) end | |||
275 | local function SEND(...) local _res, _err = linda:send("->", ...) assert(_res == true and _err == nil) end | 275 | local function SEND(...) local _res, _err = linda:send("->", ...) assert(_res == true and _err == nil) end |
276 | local function RECEIVE() local k,v = linda:receive(1, "<-") return v end | 276 | local function RECEIVE() local k,v = linda:receive(1, "<-") return v end |
277 | 277 | ||
278 | local comms_lane = lanes_gen("io", {gc_cb = gc_cb, name = "auto"}, chunk)(linda) -- prepare & launch | 278 | local comms_lane = lanes.gen("io", { name = 'auto', gc_cb = gc_cb }, chunk)(linda) -- prepare & launch |
279 | 279 | ||
280 | SEND(1); WR("main ", "1 sent\n") | 280 | SEND(1); WR("main ", "1 sent\n") |
281 | SEND(2); WR("main ", "2 sent\n") | 281 | SEND(2); WR("main ", "2 sent\n") |
@@ -355,7 +355,7 @@ local function coro_f(_x) | |||
355 | return true | 355 | return true |
356 | end | 356 | end |
357 | 357 | ||
358 | assert.fails(function() lanes_gen("xxx", {gc_cb = gc_cb}, io_os_f) end) | 358 | assert.fails(function() lanes_gen("xxx", {name = 'auto', gc_cb = gc_cb }, io_os_f) end) |
359 | 359 | ||
360 | local stdlib_naming_tests = | 360 | local stdlib_naming_tests = |
361 | { | 361 | { |
@@ -371,7 +371,7 @@ local stdlib_naming_tests = | |||
371 | } | 371 | } |
372 | 372 | ||
373 | for _, t in ipairs(stdlib_naming_tests) do | 373 | for _, t in ipairs(stdlib_naming_tests) do |
374 | local f= lanes_gen(t[1], {gc_cb = gc_cb}, t[2]) -- any delimiter will do | 374 | local f= lanes.gen(t[1], { name = 'auto', gc_cb = gc_cb }, t[2]) -- any delimiter will do |
375 | assert(f(t[1])[1]) | 375 | assert(f(t[1])[1]) |
376 | end | 376 | end |
377 | 377 | ||
@@ -386,7 +386,7 @@ PRINT("\n\n", "---=== Comms criss cross ===---", "\n\n") | |||
386 | 386 | ||
387 | -- We make two identical lanes, which are using the same Linda channel. | 387 | -- We make two identical lanes, which are using the same Linda channel. |
388 | -- | 388 | -- |
389 | local tc= lanes_gen("io", {gc_cb = gc_cb}, | 389 | local tc = lanes.gen("io", { name = 'auto', gc_cb = gc_cb }, |
390 | function(linda, ch_in, ch_out) | 390 | function(linda, ch_in, ch_out) |
391 | lane_threadname("criss cross " .. ch_in .. " -> " .. ch_out) | 391 | lane_threadname("criss cross " .. ch_in .. " -> " .. ch_out) |
392 | local function STAGE(str) | 392 | local function STAGE(str) |
@@ -453,7 +453,7 @@ local function chunk2(linda) | |||
453 | end | 453 | end |
454 | 454 | ||
455 | local linda = lanes_linda("auto") | 455 | local linda = lanes_linda("auto") |
456 | local t2= lanes_gen("debug,string,io", {gc_cb = gc_cb}, chunk2)(linda) -- prepare & launch | 456 | local t2 = lanes.gen("debug,string,io", { name = 'auto', gc_cb = gc_cb }, chunk2)(linda) -- prepare & launch |
457 | linda:send("down", function(linda) linda:send("up", "ready!") end, | 457 | linda:send("down", function(linda) linda:send("up", "ready!") end, |
458 | "ok") | 458 | "ok") |
459 | -- wait to see if the tiny function gets executed | 459 | -- wait to see if the tiny function gets executed |
@@ -486,7 +486,7 @@ PRINT("\n\n", "---=== :join test ===---", "\n\n") | |||
486 | -- (unless [1..n] has been read earlier, in which case it would seemingly | 486 | -- (unless [1..n] has been read earlier, in which case it would seemingly |
487 | -- work). | 487 | -- work). |
488 | 488 | ||
489 | local S= lanes_gen("table", {gc_cb = gc_cb}, | 489 | local S = lanes.gen("table", { name = 'auto', gc_cb = gc_cb }, |
490 | function(arg) | 490 | function(arg) |
491 | lane_threadname "join test lane" | 491 | lane_threadname "join test lane" |
492 | set_finalizer(function() end) | 492 | set_finalizer(function() end) |
diff --git a/tests/cancel.lua b/tests/cancel.lua index 5862c85..80e6c6a 100644 --- a/tests/cancel.lua +++ b/tests/cancel.lua | |||
@@ -160,7 +160,7 @@ end | |||
160 | if not next(which_tests) or which_tests.linda then | 160 | if not next(which_tests) or which_tests.linda then |
161 | remaining_tests.linda = nil | 161 | remaining_tests.linda = nil |
162 | print "\n\n####################################################################\nbegin linda cancel test\n" | 162 | print "\n\n####################################################################\nbegin linda cancel test\n" |
163 | h = generator("*", laneBody)("receive", nil) -- start an infinite wait on the linda | 163 | h = generator("*", { name = 'auto' }, laneBody)("receive", nil) -- start an infinite wait on the linda |
164 | 164 | ||
165 | print "wait 1s" | 165 | print "wait 1s" |
166 | SLEEP(1) | 166 | SLEEP(1) |
@@ -181,7 +181,7 @@ end | |||
181 | if not next(which_tests) or which_tests.soft then | 181 | if not next(which_tests) or which_tests.soft then |
182 | remaining_tests.soft = nil | 182 | remaining_tests.soft = nil |
183 | print "\n\n####################################################################\nbegin soft cancel test\n" | 183 | print "\n\n####################################################################\nbegin soft cancel test\n" |
184 | h = generator("*", protectedBody)("receive") -- start an infinite wait on the linda | 184 | h = generator("*", { name = 'auto' }, protectedBody)("receive") -- start an infinite wait on the linda |
185 | 185 | ||
186 | print "wait 1s" | 186 | print "wait 1s" |
187 | SLEEP(1) | 187 | SLEEP(1) |
@@ -205,7 +205,7 @@ end | |||
205 | if not next(which_tests) or which_tests.hook then | 205 | if not next(which_tests) or which_tests.hook then |
206 | remaining_tests.hook = nil | 206 | remaining_tests.hook = nil |
207 | print "\n\n####################################################################\nbegin hook cancel test\n" | 207 | print "\n\n####################################################################\nbegin hook cancel test\n" |
208 | h = generator("*", protectedBody)("get", 300000) | 208 | h = generator("*", { name = 'auto' }, protectedBody)("get", 300000) |
209 | print "wait 2s" | 209 | print "wait 2s" |
210 | SLEEP(2) | 210 | SLEEP(2) |
211 | 211 | ||
@@ -222,7 +222,7 @@ end | |||
222 | if not next(which_tests) or which_tests.hard then | 222 | if not next(which_tests) or which_tests.hard then |
223 | remaining_tests.hard = nil | 223 | remaining_tests.hard = nil |
224 | print "\n\n####################################################################\nbegin hard cancel test\n" | 224 | print "\n\n####################################################################\nbegin hard cancel test\n" |
225 | h = lanes.gen("*", protectedBody)("receive", nil) -- infinite timeout | 225 | h = lanes.gen("*", { name = 'auto' }, protectedBody)("receive", nil) -- infinite timeout |
226 | 226 | ||
227 | -- wait 2s before cancelling the lane | 227 | -- wait 2s before cancelling the lane |
228 | print "wait 2s" | 228 | print "wait 2s" |
@@ -241,7 +241,7 @@ end | |||
241 | if not next(which_tests) or which_tests.hard_unprotected then | 241 | if not next(which_tests) or which_tests.hard_unprotected then |
242 | remaining_tests.hard_unprotected = nil | 242 | remaining_tests.hard_unprotected = nil |
243 | print "\n\n####################################################################\nbegin hard cancel test with unprotected lane body\n" | 243 | print "\n\n####################################################################\nbegin hard cancel test with unprotected lane body\n" |
244 | h = generator("*", laneBody)("receive", nil) | 244 | h = generator("*", { name = 'auto' }, laneBody)("receive", nil) |
245 | 245 | ||
246 | -- wait 2s before cancelling the lane | 246 | -- wait 2s before cancelling the lane |
247 | print "wait 2s" | 247 | print "wait 2s" |
diff --git a/tests/cyclic.lua b/tests/cyclic.lua index ed4bdba..ca4b9f5 100644 --- a/tests/cyclic.lua +++ b/tests/cyclic.lua | |||
@@ -31,7 +31,7 @@ local function lane1() | |||
31 | assert( b[1]==a ) | 31 | assert( b[1]==a ) |
32 | return true | 32 | return true |
33 | end | 33 | end |
34 | local L1= lanes.gen( "io", lane1 )() | 34 | local L1= lanes.gen( "io", { name = 'auto' }, lane1 )() |
35 | -- ...running | 35 | -- ...running |
36 | 36 | ||
37 | -- Getting the tables as arguments should also keep the linkage | 37 | -- Getting the tables as arguments should also keep the linkage |
@@ -42,7 +42,7 @@ local function lane2( aa, bb ) | |||
42 | assert( bb[1]==aa ) | 42 | assert( bb[1]==aa ) |
43 | return true | 43 | return true |
44 | end | 44 | end |
45 | local L2= lanes.gen( "io", lane2 )( a, b ) | 45 | local L2= lanes.gen( "io", { name = 'auto' }, lane2 )( a, b ) |
46 | -- ...running | 46 | -- ...running |
47 | 47 | ||
48 | -- Really unnecessary, but let's try a directly recursive table | 48 | -- Really unnecessary, but let's try a directly recursive table |
@@ -55,7 +55,7 @@ local function lane3( cc ) | |||
55 | assert( cc and cc.a==cc ) | 55 | assert( cc and cc.a==cc ) |
56 | return true | 56 | return true |
57 | end | 57 | end |
58 | local L3= lanes.gen("io", lane3)(c) | 58 | local L3= lanes.gen("io", { name = 'auto' }, lane3)(c) |
59 | 59 | ||
60 | -- Without a wait, exit from the main lane will close the process | 60 | -- Without a wait, exit from the main lane will close the process |
61 | -- | 61 | -- |
diff --git a/tests/ehynes.lua b/tests/ehynes.lua index cdcd5a5..e4b56a5 100644 --- a/tests/ehynes.lua +++ b/tests/ehynes.lua | |||
@@ -16,7 +16,7 @@ end | |||
16 | local linda = lanes.linda() | 16 | local linda = lanes.linda() |
17 | 17 | ||
18 | -- a linda message receiver | 18 | -- a linda message receiver |
19 | local receiver_gen = lanes.gen( 'base', 'os', 'string', 'io', | 19 | local receiver_gen = lanes.gen( 'base', 'os', 'string', 'io', { name = 'auto' }, |
20 | function (message_name) | 20 | function (message_name) |
21 | PRINT_FMT( 'receiver for message %s entered', message_name ) | 21 | PRINT_FMT( 'receiver for message %s entered', message_name ) |
22 | local n = 1 | 22 | local n = 1 |
diff --git a/tests/error.lua b/tests/error.lua index 243dd57..306c51d 100644 --- a/tests/error.lua +++ b/tests/error.lua | |||
@@ -87,7 +87,7 @@ end | |||
87 | --################################################################################################## | 87 | --################################################################################################## |
88 | 88 | ||
89 | local start_lane = function(error_reporting_mode_, error_value_, finalizer_, finalizer_error_value_) | 89 | local start_lane = function(error_reporting_mode_, error_value_, finalizer_, finalizer_error_value_) |
90 | return lanes.gen("*", {error_trace_level = error_reporting_mode_}, lane_body)(error_value_, finalizer_, finalizer_error_value_) | 90 | return lanes.gen("*", { name = 'auto', error_trace_level = error_reporting_mode_ }, lane_body)(error_value_, finalizer_, finalizer_error_value_) |
91 | end | 91 | end |
92 | 92 | ||
93 | --################################################################################################## | 93 | --################################################################################################## |
diff --git a/tests/fibonacci.lua b/tests/fibonacci.lua index 7885ae6..2c043c3 100644 --- a/tests/fibonacci.lua +++ b/tests/fibonacci.lua | |||
@@ -44,7 +44,7 @@ local function fib( n ) | |||
44 | else | 44 | else |
45 | -- Splits into two; this task remains waiting for the results | 45 | -- Splits into two; this task remains waiting for the results |
46 | -- | 46 | -- |
47 | local gen_f= lanes.gen( "*", fib) | 47 | local gen_f= lanes.gen( "*", { name = 'auto' }, fib) |
48 | 48 | ||
49 | local n1=floor(n/2) +1 | 49 | local n1=floor(n/2) +1 |
50 | local n2=floor(n/2) -1 + n%2 | 50 | local n2=floor(n/2) -1 + n%2 |
diff --git a/tests/finalizer.lua b/tests/finalizer.lua index 8bf89b4..ac5ce8b 100644 --- a/tests/finalizer.lua +++ b/tests/finalizer.lua | |||
@@ -69,7 +69,7 @@ cleanup = function(err) | |||
69 | end | 69 | end |
70 | 70 | ||
71 | -- we need error_trace_level above "minimal" to get a stack trace out of h:join() | 71 | -- we need error_trace_level above "minimal" to get a stack trace out of h:join() |
72 | local lgen = lanes.gen("*", {error_trace_level = "basic"}, lane) | 72 | local lgen = lanes.gen("*", { name = 'auto', error_trace_level = "basic" }, lane) |
73 | 73 | ||
74 | local do_test = function(error_) | 74 | local do_test = function(error_) |
75 | 75 | ||
diff --git a/tests/func_is_string.lua b/tests/func_is_string.lua index a14c460..5de4c60 100644 --- a/tests/func_is_string.lua +++ b/tests/func_is_string.lua | |||
@@ -7,7 +7,7 @@ if _VERSION >= "Lua 5.4" then | |||
7 | local lanes = require 'lanes' | 7 | local lanes = require 'lanes' |
8 | local r | 8 | local r |
9 | do | 9 | do |
10 | local h <close> = lanes.gen('*', lanes.sleep)(0.5) | 10 | local h <close> = lanes.gen('*', { name = 'auto' }, lanes.sleep)(0.5) |
11 | r = h | 11 | r = h |
12 | end -- h is closed here | 12 | end -- h is closed here |
13 | return r.status | 13 | return r.status |
@@ -21,8 +21,8 @@ end | |||
21 | 21 | ||
22 | local options = {globals = { b = 666 }} | 22 | local options = {globals = { b = 666 }} |
23 | 23 | ||
24 | local gen1 = lanes.gen("*", "return true, dofile('fibonacci.lua')") | 24 | local gen1 = lanes.gen("*", { name = 'auto' }, "return true, dofile('fibonacci.lua')") |
25 | local gen2 = lanes.gen(options, "return b") | 25 | local gen2 = lanes.gen(options, { name = 'auto' }, "return b") |
26 | 26 | ||
27 | fibLane = gen1() | 27 | fibLane = gen1() |
28 | lanes.sleep(0.1) | 28 | lanes.sleep(0.1) |
diff --git a/tests/hangtest.lua b/tests/hangtest.lua index 0e44451..e48ff60 100644 --- a/tests/hangtest.lua +++ b/tests/hangtest.lua | |||
@@ -7,7 +7,7 @@ local lanes = require "lanes" | |||
7 | local function ret(b) | 7 | local function ret(b) |
8 | return b | 8 | return b |
9 | end | 9 | end |
10 | local lgen = lanes.gen("*", {}, ret) | 10 | local lgen = lanes.gen("*", { name = 'auto' }, ret) |
11 | 11 | ||
12 | for i=1,10000 do | 12 | for i=1,10000 do |
13 | local ln = lgen(i) | 13 | local ln = lgen(i) |
diff --git a/tests/irayo_closure.lua b/tests/irayo_closure.lua index 45189ec..705b85e 100644 --- a/tests/irayo_closure.lua +++ b/tests/irayo_closure.lua | |||
@@ -33,5 +33,5 @@ local function useclosurehere() | |||
33 | print "using the closure" | 33 | print "using the closure" |
34 | end | 34 | end |
35 | 35 | ||
36 | local lane= lanes.gen( "", { globals = { data=1, func=useclosurehere } }, testrun )() | 36 | local lane= lanes.gen( "", { name = 'auto', globals = { data=1, func=useclosurehere } }, testrun )() |
37 | print(lane[1]) | 37 | print(lane[1]) |
diff --git a/tests/irayo_recursive.lua b/tests/irayo_recursive.lua index 0187a15..99522f7 100644 --- a/tests/irayo_recursive.lua +++ b/tests/irayo_recursive.lua | |||
@@ -11,7 +11,7 @@ local function recurse() | |||
11 | 11 | ||
12 | --local lanes = require "lanes" | 12 | --local lanes = require "lanes" |
13 | 13 | ||
14 | local lane = lanes.gen( "base,string,lanes_core", { globals = { ["i"]= i + 1 } }, recurse ) () | 14 | local lane = lanes.gen( "base,string,lanes_core", { name = 'auto', globals = { ["i"]= i + 1 } }, recurse ) () |
15 | return lane[1] | 15 | return lane[1] |
16 | end | 16 | end |
17 | 17 | ||
diff --git a/tests/keeper.lua b/tests/keeper.lua index 0e93de2..f566927 100644 --- a/tests/keeper.lua +++ b/tests/keeper.lua | |||
@@ -160,7 +160,7 @@ if true then | |||
160 | end | 160 | end |
161 | 161 | ||
162 | PRINT("lane started") | 162 | PRINT("lane started") |
163 | local h= lanes.gen( "io", lane )() | 163 | local h= lanes.gen( "io", { name = 'auto' }, lane )() |
164 | PRINT("lane joined:", h:join()) | 164 | PRINT("lane joined:", h:join()) |
165 | 165 | ||
166 | PRINT("A.some = " .. A.some ) | 166 | PRINT("A.some = " .. A.some ) |
diff --git a/tests/lanes_as_upvalue.lua b/tests/lanes_as_upvalue.lua index e7fcd3a..beef22e 100644 --- a/tests/lanes_as_upvalue.lua +++ b/tests/lanes_as_upvalue.lua | |||
@@ -4,7 +4,7 @@ local function foo() | |||
4 | local lanes = lanes -- lanes as upvalue | 4 | local lanes = lanes -- lanes as upvalue |
5 | end | 5 | end |
6 | 6 | ||
7 | local g = lanes.gen( "*", {error_trace_level = "extended"}, foo) | 7 | local g = lanes.gen( "*", { name = 'auto', error_trace_level = "extended"}, foo) |
8 | 8 | ||
9 | -- this should raise an error as lanes.timer_lane is a Lane (a non-deep full userdata) | 9 | -- this should raise an error as lanes.timer_lane is a Lane (a non-deep full userdata) |
10 | local res, err = pcall( g) | 10 | local res, err = pcall( g) |
diff --git a/tests/launchtest.lua b/tests/launchtest.lua index 16db242..57411e1 100644 --- a/tests/launchtest.lua +++ b/tests/launchtest.lua | |||
@@ -47,7 +47,7 @@ end | |||
47 | 47 | ||
48 | local lanes = require "lanes" | 48 | local lanes = require "lanes" |
49 | 49 | ||
50 | local g= lanes.gen( LIBS, function(i) | 50 | local g= lanes.gen( LIBS, { name = 'auto' }, function(i) |
51 | --io.stderr:write( i.."\t" ) | 51 | --io.stderr:write( i.."\t" ) |
52 | return i | 52 | return i |
53 | end ) | 53 | end ) |
diff --git a/tests/linda_perf.lua b/tests/linda_perf.lua index 96f26f4..bba1408 100644 --- a/tests/linda_perf.lua +++ b/tests/linda_perf.lua | |||
@@ -79,8 +79,8 @@ end | |||
79 | 79 | ||
80 | -- ################################################################################################# | 80 | -- ################################################################################################# |
81 | 81 | ||
82 | local lane_eater_gen = lanes.gen( "*", {priority = 3}, eater) | 82 | local lane_eater_gen = lanes.gen( "*", { name = 'auto', priority = 3 }, eater) |
83 | local lane_gobbler_gen = lanes.gen( "*", {priority = 3}, gobbler) | 83 | local lane_gobbler_gen = lanes.gen( "*", { name = 'auto', priority = 3 }, gobbler) |
84 | 84 | ||
85 | -- ################################################################################################# | 85 | -- ################################################################################################# |
86 | 86 | ||
diff --git a/tests/manual_register.lua b/tests/manual_register.lua index 52cc4ed..36a41ad 100644 --- a/tests/manual_register.lua +++ b/tests/manual_register.lua | |||
@@ -25,7 +25,7 @@ local f = function() | |||
25 | end | 25 | end |
26 | 26 | ||
27 | 27 | ||
28 | local g = lanes.gen( "*", f) | 28 | local g = lanes.gen( "*", { name = 'auto' }, f) |
29 | 29 | ||
30 | -- generate a lane, this will transfer f, which pulls GlobalFunc. | 30 | -- generate a lane, this will transfer f, which pulls GlobalFunc. |
31 | local h = g() | 31 | local h = g() |
diff --git a/tests/nameof.lua b/tests/nameof.lua index 1abcf3d..fb7332a 100644 --- a/tests/nameof.lua +++ b/tests/nameof.lua | |||
@@ -18,7 +18,7 @@ local body = function() | |||
18 | end | 18 | end |
19 | 19 | ||
20 | -- start the lane without any library | 20 | -- start the lane without any library |
21 | local h = lanes.gen(nil, body)() | 21 | local h = lanes.gen(nil, { name = 'auto' }, body)() |
22 | SLEEP(0.1) | 22 | SLEEP(0.1) |
23 | print("Name of lane: ", lanes.nameof(h), "("..h.status..")") | 23 | print("Name of lane: ", lanes.nameof(h), "("..h.status..")") |
24 | assert(h.status == "running") | 24 | assert(h.status == "running") |
diff --git a/tests/objects.lua b/tests/objects.lua index ed460af..22a4df1 100644 --- a/tests/objects.lua +++ b/tests/objects.lua | |||
@@ -8,7 +8,7 @@ local lanes = require "lanes" | |||
8 | 8 | ||
9 | local linda= lanes.linda() | 9 | local linda= lanes.linda() |
10 | 10 | ||
11 | local start_lane= lanes.gen("io", | 11 | local start_lane= lanes.gen("io", { name = 'auto' }, |
12 | function(obj1 ) | 12 | function(obj1 ) |
13 | 13 | ||
14 | assert(obj1.v ) | 14 | assert(obj1.v ) |
diff --git a/tests/parallel_os_calls.lua b/tests/parallel_os_calls.lua index 8030d4c..55159e8 100644 --- a/tests/parallel_os_calls.lua +++ b/tests/parallel_os_calls.lua | |||
@@ -1,15 +1,15 @@ | |||
1 | local lanes = require "lanes" | 1 | local lanes = require "lanes" |
2 | print( os.date()) | 2 | print( os.date()) |
3 | local linda = lanes.linda() | 3 | local linda = lanes.linda() |
4 | local l1 = lanes.gen("os,base", function() print "start sleeping" linda:receive(3, "null") print("finished_sleeping " .. os.date()) return true end)() | 4 | local l1 = lanes.gen("os,base", { name = 'auto' }, function() print "start sleeping" linda:receive(3, "null") print("finished_sleeping " .. os.date()) return true end)() |
5 | lanes.gen("os,base", function() print "start sleeping" linda:receive(2, "null") print("finished_sleeping " .. os.date()) end)() | 5 | lanes.gen("os,base", { name = 'auto' }, function() print "start sleeping" linda:receive(2, "null") print("finished_sleeping " .. os.date()) end)() |
6 | lanes.gen("os,base", function() print "start sleeping" linda:receive(2, "null") print("finished_sleeping " .. os.date()) end)() | 6 | lanes.gen("os,base", { name = 'auto' }, function() print "start sleeping" linda:receive(2, "null") print("finished_sleeping " .. os.date()) end)() |
7 | lanes.gen("os,base", function() print "start sleeping" linda:receive(2, "null") print("finished_sleeping " .. os.date()) end)() | 7 | lanes.gen("os,base", { name = 'auto' }, function() print "start sleeping" linda:receive(2, "null") print("finished_sleeping " .. os.date()) end)() |
8 | -- wait, else all lanes will get hard-cancelled at stat shutdown | 8 | -- wait, else all lanes will get hard-cancelled at stat shutdown |
9 | l1:join() | 9 | l1:join() |
10 | --[[ | 10 | --[[ |
11 | lanes.gen("os,base", function() os.execute('sleep 10 && echo finished_sleeping') print( os.date()) end)() | 11 | lanes.gen("os,base", { name = 'auto' }, function() os.execute('sleep 10 && echo finished_sleeping') print( os.date()) end)() |
12 | lanes.gen("os,base", function() os.execute('sleep 10 && echo finished_sleeping') print( os.date()) end)() | 12 | lanes.gen("os,base", { name = 'auto' }, function() os.execute('sleep 10 && echo finished_sleeping') print( os.date()) end)() |
13 | lanes.gen("os,base", function() os.execute('sleep 10 && echo finished_sleeping') print( os.date()) end)() | 13 | lanes.gen("os,base", { name = 'auto' }, function() os.execute('sleep 10 && echo finished_sleeping') print( os.date()) end)() |
14 | lanes.gen("os,base", function() os.execute('sleep 10 && echo finished_sleeping') print( os.date()) end)() | 14 | lanes.gen("os,base", { name = 'auto' }, function() os.execute('sleep 10 && echo finished_sleeping') print( os.date()) end)() |
15 | ]] | 15 | ]] |
diff --git a/tests/perftest.lua b/tests/perftest.lua index 35f522c..fe43cca 100644 --- a/tests/perftest.lua +++ b/tests/perftest.lua | |||
@@ -137,10 +137,10 @@ end | |||
137 | -- Keep preparation code outside of the performance test | 137 | -- Keep preparation code outside of the performance test |
138 | -- | 138 | -- |
139 | local f_even= lanes.gen( "base,coroutine,math,table,io", -- "*" = all | 139 | local f_even= lanes.gen( "base,coroutine,math,table,io", -- "*" = all |
140 | { priority= PRIO_EVEN }, sieve_lane ) | 140 | { name = 'auto', priority= PRIO_EVEN }, sieve_lane ) |
141 | 141 | ||
142 | local f_odd= lanes.gen( "base,coroutine,math,table,io", -- "*" = all | 142 | local f_odd= lanes.gen( "base,coroutine,math,table,io", -- "*" = all |
143 | { priority= PRIO_ODD }, sieve_lane ) | 143 | { name = 'auto', priority= PRIO_ODD }, sieve_lane ) |
144 | 144 | ||
145 | io.stderr:write( "*** Counting primes 1.."..M.." "..N.." times ***\n\n" ) | 145 | io.stderr:write( "*** Counting primes 1.."..M.." "..N.." times ***\n\n" ) |
146 | 146 | ||
diff --git a/tests/pingpong.lua b/tests/pingpong.lua index 3498f49..06c0903 100644 --- a/tests/pingpong.lua +++ b/tests/pingpong.lua | |||
@@ -25,8 +25,8 @@ local pingpong = function(name, qr, qs, start) | |||
25 | end | 25 | end |
26 | 26 | ||
27 | -- pingpong("L1", '0', '1', true) | 27 | -- pingpong("L1", '0', '1', true) |
28 | local t1, err1 = lanes.gen("*", pingpong)("L1", 'a', 'b', true) | 28 | local t1, err1 = lanes.gen("*", { name = 'auto' }, pingpong)("L1", 'a', 'b', true) |
29 | local t2, err2 = lanes.gen("*", pingpong)("L2", 'b', 'a', false) | 29 | local t2, err2 = lanes.gen("*", { name = 'auto' }, pingpong)("L2", 'b', 'a', false) |
30 | 30 | ||
31 | t1:join() | 31 | t1:join() |
32 | t2:join() | 32 | t2:join() |
diff --git a/tests/protect_allocator.lua b/tests/protect_allocator.lua index 994cb39..e13a57c 100644 --- a/tests/protect_allocator.lua +++ b/tests/protect_allocator.lua | |||
@@ -36,7 +36,7 @@ end | |||
36 | 36 | ||
37 | -- start threads | 37 | -- start threads |
38 | local COUNT = 4 | 38 | local COUNT = 4 |
39 | local gen = lanes.gen( "*", body) | 39 | local gen = lanes.gen( "*", { name = 'auto' }, body) |
40 | for i = 1, COUNT do | 40 | for i = 1, COUNT do |
41 | gen( i) | 41 | gen( i) |
42 | end | 42 | end |
diff --git a/tests/protectproxy.lua b/tests/protectproxy.lua index ed1bd4f..84887ec 100644 --- a/tests/protectproxy.lua +++ b/tests/protectproxy.lua | |||
@@ -5,7 +5,7 @@ local body = function( param) | |||
5 | return 1 | 5 | return 1 |
6 | end | 6 | end |
7 | 7 | ||
8 | local gen = lanes.gen( "*", body) | 8 | local gen = lanes.gen( "*", { name = 'auto' }, body) |
9 | 9 | ||
10 | local mylane = gen( "hello") | 10 | local mylane = gen( "hello") |
11 | 11 | ||
diff --git a/tests/recursive.lua b/tests/recursive.lua index 716fe60..e294104 100644 --- a/tests/recursive.lua +++ b/tests/recursive.lua | |||
@@ -12,7 +12,7 @@ local function func( depth ) | |||
12 | end | 12 | end |
13 | 13 | ||
14 | local lanes = require "lanes" | 14 | local lanes = require "lanes" |
15 | local lane = lanes.gen("*", func)( depth-1 ) | 15 | local lane = lanes.gen("*", { name = 'auto' }, func)( depth-1 ) |
16 | return lane[1] | 16 | return lane[1] |
17 | end | 17 | end |
18 | 18 | ||
diff --git a/tests/require.lua b/tests/require.lua index b194af1..f017ddf 100644 --- a/tests/require.lua +++ b/tests/require.lua | |||
@@ -19,14 +19,14 @@ local function a_lane() | |||
19 | local lanes = require "lanes" | 19 | local lanes = require "lanes" |
20 | assert( lanes and lanes.gen ) | 20 | assert( lanes and lanes.gen ) |
21 | 21 | ||
22 | local h= lanes.gen( function() return 42 end ) () | 22 | local h= lanes.gen( { name = 'auto' }, function() return 42 end ) () |
23 | local v= h[1] | 23 | local v= h[1] |
24 | 24 | ||
25 | return v==42 | 25 | return v==42 |
26 | end | 26 | end |
27 | 27 | ||
28 | -- string and table for Lanes itself, package to be able to require in the lane, math for the actual work | 28 | -- string and table for Lanes itself, package to be able to require in the lane, math for the actual work |
29 | local gen= lanes.gen( "math,package,string,table", {package={}},a_lane ) | 29 | local gen= lanes.gen( "math,package,string,table", { name = 'auto', package={} },a_lane ) |
30 | 30 | ||
31 | local h= gen() | 31 | local h= gen() |
32 | local ret= h[1] | 32 | local ret= h[1] |
diff --git a/tests/rupval.lua b/tests/rupval.lua index 122e0ac..ad5ad9d 100644 --- a/tests/rupval.lua +++ b/tests/rupval.lua | |||
@@ -23,7 +23,7 @@ c = function( n) | |||
23 | return n <= 0 and z or a( n-1) | 23 | return n <= 0 and z or a( n-1) |
24 | end | 24 | end |
25 | 25 | ||
26 | local g = lanes.gen( "base", a) | 26 | local g = lanes.gen( "base", { name = 'auto' }, a) |
27 | 27 | ||
28 | local l = g(7) | 28 | local l = g(7) |
29 | local r = l:join() | 29 | local r = l:join() |
diff --git a/tests/tobeclosed.lua b/tests/tobeclosed.lua index 7a5e3ae..ef09df3 100644 --- a/tests/tobeclosed.lua +++ b/tests/tobeclosed.lua | |||
@@ -86,7 +86,7 @@ do | |||
86 | return "success" | 86 | return "success" |
87 | end | 87 | end |
88 | 88 | ||
89 | local h = lanes.gen("*", lane_body)() | 89 | local h = lanes.gen("*", { name = 'auto' }, lane_body)() |
90 | do | 90 | do |
91 | local tobeclosed <close> = h | 91 | local tobeclosed <close> = h |
92 | end | 92 | end |
@@ -118,7 +118,7 @@ do | |||
118 | l:set("trip", l_in) | 118 | l:set("trip", l_in) |
119 | 119 | ||
120 | do | 120 | do |
121 | lanes.gen("*", lane_body)(l_in):join() | 121 | lanes.gen("*", { name = 'auto' }, lane_body)(l_in):join() |
122 | end | 122 | end |
123 | local _count, _closed = l_in:get("closed") | 123 | local _count, _closed = l_in:get("closed") |
124 | assert(_count == 1 and _closed == 2) | 124 | assert(_count == 1 and _closed == 2) |
diff --git a/tests/track_lanes.lua b/tests/track_lanes.lua index 803fae5..d1670ae 100644 --- a/tests/track_lanes.lua +++ b/tests/track_lanes.lua | |||
@@ -43,7 +43,7 @@ end | |||
43 | -- sleeper( "main", 1) | 43 | -- sleeper( "main", 1) |
44 | 44 | ||
45 | -- the generator | 45 | -- the generator |
46 | local g = lanes.gen( "*", sleeper) | 46 | local g = lanes.gen( "*", { name = 'auto' }, sleeper) |
47 | 47 | ||
48 | -- start a forever-waiting lane (nil timeout) | 48 | -- start a forever-waiting lane (nil timeout) |
49 | local forever = g( "forever", 'indefinitely') | 49 | local forever = g( "forever", 'indefinitely') |
diff --git a/unit_tests/embedded_tests.cpp b/unit_tests/embedded_tests.cpp index a63383a..9a262d5 100644 --- a/unit_tests/embedded_tests.cpp +++ b/unit_tests/embedded_tests.cpp | |||
@@ -234,7 +234,7 @@ TEST_CASE("lanes.embedding.with custom allocator") | |||
234 | // lua_setfield(L, -2, "allocator"); // configure {on_state_create = on_state_create_, allocater = "protected"} | 234 | // lua_setfield(L, -2, "allocator"); // configure {on_state_create = on_state_create_, allocater = "protected"} |
235 | lua_pcall(L, 1, 0, 0); | 235 | lua_pcall(L, 1, 0, 0); |
236 | sprintf_s(script, | 236 | sprintf_s(script, |
237 | "g = lanes.gen('*', {globals = {ID = %d}}, function(id_) lane_threadname('Lane %d.'..id_) logPrint('This is L%d.'..id_) end)" // lane generator | 237 | "g = lanes.gen('*', { name = 'auto', globals = {ID = %d} }, function(id_) lane_threadname('Lane %d.'..id_) logPrint('This is L%d.'..id_) end)" // lane generator |
238 | "for i = 1,%d do _G['a'..i] = g(i) end" // launch a few lanes, handle stored in global a<i> | 238 | "for i = 1,%d do _G['a'..i] = g(i) end" // launch a few lanes, handle stored in global a<i> |
239 | , | 239 | , |
240 | id_, | 240 | id_, |
diff --git a/unit_tests/init_and_shutdown.cpp b/unit_tests/init_and_shutdown.cpp index 7e4c215..9652f2d 100644 --- a/unit_tests/init_and_shutdown.cpp +++ b/unit_tests/init_and_shutdown.cpp | |||
@@ -829,6 +829,7 @@ TEST_CASE("lanes.on_state_create setting") | |||
829 | // launch a Lane that requires the module. It should succeed because _on_state_create was called and made it possible | 829 | // launch a Lane that requires the module. It should succeed because _on_state_create was called and made it possible |
830 | std::string_view const _script{ | 830 | std::string_view const _script{ |
831 | " f = lanes.gen('*'," | 831 | " f = lanes.gen('*'," |
832 | " { name = 'auto' }," | ||
832 | " function()" | 833 | " function()" |
833 | " local Stuff = require ('Stuff')" | 834 | " local Stuff = require ('Stuff')" |
834 | " Stuff.DoStuffInC()" | 835 | " Stuff.DoStuffInC()" |
diff --git a/unit_tests/lane_tests.cpp b/unit_tests/lane_tests.cpp index bf239ba..0c4feba 100644 --- a/unit_tests/lane_tests.cpp +++ b/unit_tests/lane_tests.cpp | |||
@@ -80,7 +80,7 @@ TEST_CASE("lanes.sleep.interactions with timers") | |||
80 | " local l = lanes.linda()" | 80 | " local l = lanes.linda()" |
81 | " lanes.timer(l, 'gluh', 0.1, 0.1)" | 81 | " lanes.timer(l, 'gluh', 0.1, 0.1)" |
82 | // launch a lane that is supposed to sleep forever | 82 | // launch a lane that is supposed to sleep forever |
83 | " local g = lanes.gen('*', lanes.sleep)" | 83 | " local g = lanes.gen('*', { name = 'auto' }, lanes.sleep)" |
84 | " local h = g('indefinitely')" | 84 | " local h = g('indefinitely')" |
85 | // sleep 1 second (this uses the timer linda) | 85 | // sleep 1 second (this uses the timer linda) |
86 | " lanes.sleep(1)" | 86 | " lanes.sleep(1)" |
diff --git a/unit_tests/scripts/coro/basics.lua b/unit_tests/scripts/coro/basics.lua index dc74b7c..cd2f410 100644 --- a/unit_tests/scripts/coro/basics.lua +++ b/unit_tests/scripts/coro/basics.lua | |||
@@ -42,7 +42,7 @@ end | |||
42 | 42 | ||
43 | if true then | 43 | if true then |
44 | -- if we start a non-coroutine lane with a yielding function, we should get an error, right? | 44 | -- if we start a non-coroutine lane with a yielding function, we should get an error, right? |
45 | local fun_g = lanes.gen("*", {name = "auto"}, yielder) | 45 | local fun_g = lanes.gen("*", { name = 'auto' }, yielder) |
46 | local h = fun_g("hello", "world", "!") | 46 | local h = fun_g("hello", "world", "!") |
47 | local err, status, stack = h:join() | 47 | local err, status, stack = h:join() |
48 | PRINT(err, status, stack) | 48 | PRINT(err, status, stack) |
diff --git a/unit_tests/scripts/lane/cooperative_shutdown.lua b/unit_tests/scripts/lane/cooperative_shutdown.lua index 1204e35..756e33c 100644 --- a/unit_tests/scripts/lane/cooperative_shutdown.lua +++ b/unit_tests/scripts/lane/cooperative_shutdown.lua | |||
@@ -31,9 +31,9 @@ end | |||
31 | 31 | ||
32 | 32 | ||
33 | -- the generators | 33 | -- the generators |
34 | local g1 = lanes.gen("*", lane1) | 34 | local g1 = lanes.gen("*", { name = 'auto' }, lane1) |
35 | local g2 = lanes.gen("*", lane2) | 35 | local g2 = lanes.gen("*", { name = 'auto' }, lane2) |
36 | local g3 = lanes.gen("*", lane3) | 36 | local g3 = lanes.gen("*", { name = 'auto' }, lane3) |
37 | 37 | ||
38 | -- launch lanes | 38 | -- launch lanes |
39 | local h1 = g1() | 39 | local h1 = g1() |
diff --git a/unit_tests/scripts/lane/stdlib_naming.lua b/unit_tests/scripts/lane/stdlib_naming.lua index 2e045c3..4884cca 100644 --- a/unit_tests/scripts/lane/stdlib_naming.lua +++ b/unit_tests/scripts/lane/stdlib_naming.lua | |||
@@ -63,7 +63,7 @@ local function coro_f(_x) | |||
63 | return true | 63 | return true |
64 | end | 64 | end |
65 | 65 | ||
66 | assert.fails(function() lanes_gen("xxx", {gc_cb = gc_cb}, io_os_f) end) | 66 | assert.fails(function() lanes_gen("xxx", { name = 'auto', gc_cb = gc_cb }, io_os_f) end) |
67 | 67 | ||
68 | local stdlib_naming_tests = | 68 | local stdlib_naming_tests = |
69 | { | 69 | { |
diff --git a/unit_tests/scripts/lane/tasking_basic.lua b/unit_tests/scripts/lane/tasking_basic.lua index 99be321..233accf 100644 --- a/unit_tests/scripts/lane/tasking_basic.lua +++ b/unit_tests/scripts/lane/tasking_basic.lua | |||
@@ -39,7 +39,7 @@ end | |||
39 | 39 | ||
40 | PRINT("\n\n", "---=== Tasking (basic) ===---", "\n\n") | 40 | PRINT("\n\n", "---=== Tasking (basic) ===---", "\n\n") |
41 | 41 | ||
42 | local task_launch = lanes_gen("", { globals={hey=true}, gc_cb = gc_cb}, task) | 42 | local task_launch = lanes_gen("", { name = 'auto', globals={hey=true}, gc_cb = gc_cb }, task) |
43 | -- base stdlibs, normal priority | 43 | -- base stdlibs, normal priority |
44 | 44 | ||
45 | -- 'task_launch' is a factory of multithreaded tasks, we can launch several: | 45 | -- 'task_launch' is a factory of multithreaded tasks, we can launch several: |
diff --git a/unit_tests/scripts/lane/tasking_cancelling.lua b/unit_tests/scripts/lane/tasking_cancelling.lua index a4e0fde..85600ab 100644 --- a/unit_tests/scripts/lane/tasking_cancelling.lua +++ b/unit_tests/scripts/lane/tasking_cancelling.lua | |||
@@ -36,7 +36,7 @@ end | |||
36 | 36 | ||
37 | PRINT("\n\n", "---=== Tasking (cancelling) ===---", "\n\n") | 37 | PRINT("\n\n", "---=== Tasking (cancelling) ===---", "\n\n") |
38 | 38 | ||
39 | local task_launch2 = lanes_gen("", { globals={hey=true}, gc_cb = gc_cb}, task) | 39 | local task_launch2 = lanes_gen("", { name = 'auto', globals={hey=true}, gc_cb = gc_cb }, task) |
40 | 40 | ||
41 | local N=999999999 | 41 | local N=999999999 |
42 | local lane9= task_launch2(1,N,1) -- huuuuuuge... | 42 | local lane9= task_launch2(1,N,1) -- huuuuuuge... |
@@ -87,7 +87,7 @@ local wait_send = function() | |||
87 | a,b = limited:send("key", "bybye") -- infinite timeout, returns only when lane is cancelled | 87 | a,b = limited:send("key", "bybye") -- infinite timeout, returns only when lane is cancelled |
88 | end | 88 | end |
89 | 89 | ||
90 | local wait_send_lane = lanes.gen("*", wait_send)() | 90 | local wait_send_lane = lanes_gen("*", { name = 'auto' }, wait_send)() |
91 | repeat until wait_send_lane.status == "waiting" | 91 | repeat until wait_send_lane.status == "waiting" |
92 | print "wait_send_lane is waiting" | 92 | print "wait_send_lane is waiting" |
93 | wait_send_lane:cancel() -- hard cancel, 0 timeout | 93 | wait_send_lane:cancel() -- hard cancel, 0 timeout |
@@ -100,7 +100,7 @@ local wait_receive = function() | |||
100 | k, v = limited:receive("dummy") -- infinite timeout, returns only when lane is cancelled | 100 | k, v = limited:receive("dummy") -- infinite timeout, returns only when lane is cancelled |
101 | end | 101 | end |
102 | 102 | ||
103 | local wait_receive_lane = lanes.gen("*", wait_receive)() | 103 | local wait_receive_lane = lanes_gen("*", { name = 'auto' }, wait_receive)() |
104 | repeat until wait_receive_lane.status == "waiting" | 104 | repeat until wait_receive_lane.status == "waiting" |
105 | print "wait_receive_lane is waiting" | 105 | print "wait_receive_lane is waiting" |
106 | wait_receive_lane:cancel() -- hard cancel, 0 timeout | 106 | wait_receive_lane:cancel() -- hard cancel, 0 timeout |
@@ -113,7 +113,7 @@ local wait_receive_batched = function() | |||
113 | k, v1, v2 = limited:receive(limited.batched, "dummy", 2) -- infinite timeout, returns only when lane is cancelled | 113 | k, v1, v2 = limited:receive(limited.batched, "dummy", 2) -- infinite timeout, returns only when lane is cancelled |
114 | end | 114 | end |
115 | 115 | ||
116 | local wait_receive_batched_lane = lanes.gen("*", wait_receive_batched)() | 116 | local wait_receive_batched_lane = lanes_gen("*", { name = 'auto' }, wait_receive_batched)() |
117 | repeat until wait_receive_batched_lane.status == "waiting" | 117 | repeat until wait_receive_batched_lane.status == "waiting" |
118 | print "wait_receive_batched_lane is waiting" | 118 | print "wait_receive_batched_lane is waiting" |
119 | wait_receive_batched_lane:cancel() -- hard cancel, 0 timeout | 119 | wait_receive_batched_lane:cancel() -- hard cancel, 0 timeout |
diff --git a/unit_tests/scripts/lane/tasking_comms_criss_cross.lua b/unit_tests/scripts/lane/tasking_comms_criss_cross.lua index db63b8e..497e81d 100644 --- a/unit_tests/scripts/lane/tasking_comms_criss_cross.lua +++ b/unit_tests/scripts/lane/tasking_comms_criss_cross.lua | |||
@@ -27,7 +27,7 @@ PRINT("\n\n", "---=== Comms criss cross ===---", "\n\n") | |||
27 | 27 | ||
28 | -- We make two identical lanes, which are using the same Linda channel. | 28 | -- We make two identical lanes, which are using the same Linda channel. |
29 | -- | 29 | -- |
30 | local tc = lanes_gen("io", {gc_cb = gc_cb}, | 30 | local tc = lanes_gen("io", { name = 'auto', gc_cb = gc_cb }, |
31 | function(linda, ch_in, ch_out) | 31 | function(linda, ch_in, ch_out) |
32 | lane_threadname("criss cross " .. ch_in .. " -> " .. ch_out) | 32 | lane_threadname("criss cross " .. ch_in .. " -> " .. ch_out) |
33 | local function STAGE(str) | 33 | local function STAGE(str) |
diff --git a/unit_tests/scripts/lane/tasking_communications.lua b/unit_tests/scripts/lane/tasking_communications.lua index b922973..1fd43b0 100644 --- a/unit_tests/scripts/lane/tasking_communications.lua +++ b/unit_tests/scripts/lane/tasking_communications.lua | |||
@@ -101,7 +101,7 @@ local function PEEK(...) return linda:get("<-", ...) end | |||
101 | local function SEND(...) local _res, _err = linda:send("->", ...) assert(_res == true and _err == nil) end | 101 | local function SEND(...) local _res, _err = linda:send("->", ...) assert(_res == true and _err == nil) end |
102 | local function RECEIVE() local k,v = linda:receive(1, "<-") return v end | 102 | local function RECEIVE() local k,v = linda:receive(1, "<-") return v end |
103 | 103 | ||
104 | local comms_lane = lanes_gen("io", {gc_cb = gc_cb, name = "auto"}, chunk)(linda) -- prepare & launch | 104 | local comms_lane = lanes_gen("io", { name = 'auto', gc_cb = gc_cb }, chunk)(linda) -- prepare & launch |
105 | 105 | ||
106 | SEND(1); WR("main ", "1 sent\n") | 106 | SEND(1); WR("main ", "1 sent\n") |
107 | SEND(2); WR("main ", "2 sent\n") | 107 | SEND(2); WR("main ", "2 sent\n") |
diff --git a/unit_tests/scripts/lane/tasking_error.lua b/unit_tests/scripts/lane/tasking_error.lua index 1e2347f..26f244b 100644 --- a/unit_tests/scripts/lane/tasking_error.lua +++ b/unit_tests/scripts/lane/tasking_error.lua | |||
@@ -22,7 +22,7 @@ end | |||
22 | PRINT("---=== Tasking (error) ===---", "\n\n") | 22 | PRINT("---=== Tasking (error) ===---", "\n\n") |
23 | 23 | ||
24 | -- a lane that throws immediately the error value it received | 24 | -- a lane that throws immediately the error value it received |
25 | local g = lanes_gen("", {gc_cb = gc_cb}, error) | 25 | local g = lanes_gen("", { name = 'auto', gc_cb = gc_cb }, error) |
26 | local errmsg = "ERROR!" | 26 | local errmsg = "ERROR!" |
27 | 27 | ||
28 | if true then | 28 | if true then |
diff --git a/unit_tests/scripts/lane/tasking_join_test.lua b/unit_tests/scripts/lane/tasking_join_test.lua index 8f2d4db..2fbce6c 100644 --- a/unit_tests/scripts/lane/tasking_join_test.lua +++ b/unit_tests/scripts/lane/tasking_join_test.lua | |||
@@ -34,7 +34,7 @@ PRINT("---=== :join test ===---", "\n\n") | |||
34 | -- (unless [1..n] has been read earlier, in which case it would seemingly | 34 | -- (unless [1..n] has been read earlier, in which case it would seemingly |
35 | -- work). | 35 | -- work). |
36 | 36 | ||
37 | local S= lanes_gen("table", {gc_cb = gc_cb}, | 37 | local S= lanes_gen("table", { name = 'auto', gc_cb = gc_cb }, |
38 | function(arg) | 38 | function(arg) |
39 | lane_threadname "join test lane" | 39 | lane_threadname "join test lane" |
40 | set_finalizer(function() end) | 40 | set_finalizer(function() end) |
diff --git a/unit_tests/scripts/lane/tasking_send_receive_code.lua b/unit_tests/scripts/lane/tasking_send_receive_code.lua index 77a4b12..e329a88 100644 --- a/unit_tests/scripts/lane/tasking_send_receive_code.lua +++ b/unit_tests/scripts/lane/tasking_send_receive_code.lua | |||
@@ -66,7 +66,7 @@ local function chunk2(linda) | |||
66 | end | 66 | end |
67 | 67 | ||
68 | local linda = lanes_linda("auto") | 68 | local linda = lanes_linda("auto") |
69 | local t2= lanes_gen("debug,package,string,io", {gc_cb = gc_cb}, chunk2)(linda) -- prepare & launch | 69 | local t2= lanes_gen("debug,package,string,io", { name = 'auto', gc_cb = gc_cb }, chunk2)(linda) -- prepare & launch |
70 | linda:send("down", function(linda) linda:send("up", "ready!") end, | 70 | linda:send("down", function(linda) linda:send("up", "ready!") end, |
71 | "ok") | 71 | "ok") |
72 | -- wait to see if the tiny function gets executed | 72 | -- wait to see if the tiny function gets executed |
diff --git a/unit_tests/scripts/lane/uncooperative_shutdown.lua b/unit_tests/scripts/lane/uncooperative_shutdown.lua index 56c936b..51e5762 100644 --- a/unit_tests/scripts/lane/uncooperative_shutdown.lua +++ b/unit_tests/scripts/lane/uncooperative_shutdown.lua | |||
@@ -12,7 +12,7 @@ local lane = function() | |||
12 | end | 12 | end |
13 | 13 | ||
14 | -- the generator | 14 | -- the generator |
15 | local g1 = lanes.gen("*", {name = "auto"}, lane) | 15 | local g1 = lanes.gen("*", { name = 'auto' }, lane) |
16 | 16 | ||
17 | -- launch lane | 17 | -- launch lane |
18 | local h1 = g1() | 18 | local h1 = g1() |