From 9c0a1bfc6eea9a2e68de7206d8d5af5188f22e59 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Mon, 6 May 2024 15:37:44 +0200 Subject: new lane generator option opt_tbl.name --- src/lanes.lua | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/lanes.lua') diff --git a/src/lanes.lua b/src/lanes.lua index 8a2592b..f95dddf 100644 --- a/src/lanes.lua +++ b/src/lanes.lua @@ -208,25 +208,29 @@ end local opt_validators = { - priority = function(v_) + gc_cb = function(v_) local tv = type(v_) - return (tv == "number") and v_ or raise_option_error("priority", tv, v_) + return (tv == "function") and v_ or raise_option_error("gc_cb", tv, v_) end, globals = function(v_) local tv = type(v_) return (tv == "table") and v_ or raise_option_error("globals", tv, v_) end, + name = function(v_) + local tv = type(v_) + return (tv == "string") and v_ or raise_option_error("name", tv, v_) + end, package = function(v_) local tv = type(v_) return (tv == "table") and v_ or raise_option_error("package", tv, v_) end, - required = function(v_) + priority = function(v_) local tv = type(v_) - return (tv == "table") and v_ or raise_option_error("required", tv, v_) + return (tv == "number") and v_ or raise_option_error("priority", tv, v_) end, - gc_cb = function(v_) + required = function(v_) local tv = type(v_) - return (tv == "function") and v_ or raise_option_error("gc_cb", tv, v_) + return (tv == "table") and v_ or raise_option_error("required", tv, v_) end } @@ -338,10 +342,10 @@ local gen = function(...) end local core_lane_new = assert(core.lane_new) - local priority, globals, package, required, gc_cb = opt.priority, opt.globals, opt.package or package, opt.required, opt.gc_cb + local priority, globals, package, required, gc_cb, name = opt.priority, opt.globals, opt.package or package, opt.required, opt.gc_cb, opt.name return function(...) -- must pass functions args last else they will be truncated to the first one - return core_lane_new(func, libs, priority, globals, package, required, gc_cb, ...) + return core_lane_new(func, libs, priority, globals, package, required, gc_cb, name, ...) end end -- gen() @@ -569,7 +573,7 @@ local configure_timers = function() end end end -- timer_body() - timer_lane = gen("*", { package= {}, priority = core.max_prio}, timer_body)() -- "*" instead of "io,package" for LuaJIT compatibility... + timer_lane = gen("*", { package= {}, priority = core.max_prio, name = "LanesTimer"}, timer_body)() -- "*" instead of "io,package" for LuaJIT compatibility... end -- first_time ----- -- cgit v1.2.3-55-g6feb