diff options
Diffstat (limited to 'src/lanes.lua')
-rw-r--r-- | src/lanes.lua | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/lanes.lua b/src/lanes.lua index 9a0287d..1286099 100644 --- a/src/lanes.lua +++ b/src/lanes.lua | |||
@@ -196,7 +196,10 @@ end | |||
196 | -- | 196 | -- |
197 | -- .globals: table of globals to set for a new thread (passed by value) | 197 | -- .globals: table of globals to set for a new thread (passed by value) |
198 | -- | 198 | -- |
199 | -- .required: table of packages to require | 199 | -- .required: table of packages to require |
200 | -- | ||
201 | -- .gc_cb: function called when the lane handle is collected | ||
202 | -- | ||
200 | -- ... (more options may be introduced later) ... | 203 | -- ... (more options may be introduced later) ... |
201 | -- | 204 | -- |
202 | -- Calling with a function parameter ('lane_func') ends the string/table | 205 | -- Calling with a function parameter ('lane_func') ends the string/table |
@@ -272,10 +275,11 @@ local function gen( ... ) | |||
272 | end | 275 | end |
273 | end | 276 | end |
274 | 277 | ||
275 | local prio, cs, g_tbl, package_tbl, required | 278 | local prio, cs, g_tbl, package_tbl, required, gc_cb |
276 | 279 | ||
277 | for k,v in pairs(opt) do | 280 | for k,v in pairs(opt) do |
278 | if k=="priority" then prio= v | 281 | if k == "priority" then |
282 | prio = (type( v) == "number") and v or error( "Bad 'prio' option: expecting number, got " .. type( v), lev) | ||
279 | elseif k=="cancelstep" then | 283 | elseif k=="cancelstep" then |
280 | cs = (v==true) and 100 or | 284 | cs = (v==true) and 100 or |
281 | (v==false) and 0 or | 285 | (v==false) and 0 or |
@@ -286,6 +290,8 @@ local function gen( ... ) | |||
286 | package_tbl = (type( v) == "table") and v or error( "Bad package: " .. tostring( v), lev) | 290 | package_tbl = (type( v) == "table") and v or error( "Bad package: " .. tostring( v), lev) |
287 | elseif k=="required" then | 291 | elseif k=="required" then |
288 | required= (type( v) == "table") and v or error( "Bad 'required' option: expecting table, got " .. type( v), lev) | 292 | required= (type( v) == "table") and v or error( "Bad 'required' option: expecting table, got " .. type( v), lev) |
293 | elseif k == "gc_cb" then | ||
294 | gc_cb = (type( v) == "function") and v or error( "Bad 'gc_cb' option: expecting function, got " .. type( v), lev) | ||
289 | --.. | 295 | --.. |
290 | elseif k==1 then error( "unkeyed option: ".. tostring(v), lev ) | 296 | elseif k==1 then error( "unkeyed option: ".. tostring(v), lev ) |
291 | else error( "Bad option: ".. tostring(k), lev ) | 297 | else error( "Bad option: ".. tostring(k), lev ) |
@@ -296,7 +302,7 @@ local function gen( ... ) | |||
296 | -- Lane generator | 302 | -- Lane generator |
297 | -- | 303 | -- |
298 | return function(...) | 304 | return function(...) |
299 | return thread_new( func, libs, cs, prio, g_tbl, package_tbl, required, ...) -- args | 305 | return thread_new( func, libs, cs, prio, g_tbl, package_tbl, required, gc_cb, ...) -- args |
300 | end | 306 | end |
301 | end | 307 | end |
302 | 308 | ||