aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lanes.lua53
1 files changed, 25 insertions, 28 deletions
diff --git a/src/lanes.lua b/src/lanes.lua
index 6616667..982de98 100644
--- a/src/lanes.lua
+++ b/src/lanes.lua
@@ -51,12 +51,13 @@ local lanes = {}
51-- 51--
52local assert = assert(assert) 52local assert = assert(assert)
53local error = assert(error) 53local error = assert(error)
54local io = assert(io)
55local pairs = assert(pairs) 54local pairs = assert(pairs)
55local string = assert(string, "'string' library not available")
56local string_gmatch = assert(string.gmatch) 56local string_gmatch = assert(string.gmatch)
57local string_format = assert(string.format) 57local string_format = assert(string.format)
58local select = assert(select) 58local select = assert(select)
59local setmetatable = assert(setmetatable) 59local setmetatable = assert(setmetatable)
60local table = assert(table, "'table' library not available")
60local table_insert = assert(table.insert) 61local table_insert = assert(table.insert)
61local tonumber = assert(tonumber) 62local tonumber = assert(tonumber)
62local tostring = assert(tostring) 63local tostring = assert(tostring)
@@ -64,6 +65,27 @@ local type = assert(type)
64 65
65-- ################################################################################################# 66-- #################################################################################################
66 67
68-- for error reporting when debugging stuff
69--[[
70local io = assert(io, "'io' library not available")
71local function WR(str)
72 io.stderr:write(str.."\n" )
73end
74
75-- #################################################################################################
76
77local function DUMP(tbl)
78 if not tbl then return end
79 local str=""
80 for k,v in pairs(tbl) do
81 str= str..k.."="..tostring(v).."\n"
82 end
83 WR(str)
84end
85]]
86
87-- #################################################################################################
88
67local isLuaJIT = (package and package.loaded.jit and jit.version) and true or false 89local isLuaJIT = (package and package.loaded.jit and jit.version) and true or false
68 90
69local default_params = 91local default_params =
@@ -163,23 +185,6 @@ end
163 185
164-- ################################################################################################# 186-- #################################################################################################
165 187
166local function WR(str)
167 io.stderr:write(str.."\n" )
168end
169
170-- #################################################################################################
171
172local function DUMP(tbl)
173 if not tbl then return end
174 local str=""
175 for k,v in pairs(tbl) do
176 str= str..k.."="..tostring(v).."\n"
177 end
178 WR(str)
179end
180
181-- #################################################################################################
182
183local valid_libs = 188local valid_libs =
184{ 189{
185 ["package"] = true, 190 ["package"] = true,
@@ -550,7 +555,7 @@ local configure_timers = function()
550 local timer_gateway_batched = timer_gateway.batched 555 local timer_gateway_batched = timer_gateway.batched
551 set_finalizer(function(err, stk) 556 set_finalizer(function(err, stk)
552 if err and type(err) ~= "userdata" then 557 if err and type(err) ~= "userdata" then
553 WR("LanesTimer error: "..tostring(err)) 558 error("LanesTimer error: "..tostring(err))
554 --elseif type(err) == "userdata" then 559 --elseif type(err) == "userdata" then
555 -- WR("LanesTimer after cancel" ) 560 -- WR("LanesTimer after cancel" )
556 --else 561 --else
@@ -585,7 +590,7 @@ local configure_timers = function()
585 end 590 end
586 end 591 end
587 end -- timer_body() 592 end -- timer_body()
588 timer_lane = gen("*", { package= {}, priority = core.max_prio, name = "LanesTimer"}, timer_body)() -- "*" instead of "io,package" for LuaJIT compatibility... 593 timer_lane = gen("lanes.core,table", { name = "LanesTimer", package = {}, priority = core.max_prio }, timer_body)()
589 end -- first_time 594 end -- first_time
590 595
591 ----- 596 -----
@@ -761,14 +766,6 @@ local configure = function(settings_)
761 setmetatable(lanes, nil) -- remove it 766 setmetatable(lanes, nil) -- remove it
762 lanes.configure = nil -- no need to call configure() ever again 767 lanes.configure = nil -- no need to call configure() ever again
763 768
764 -- This check is for sublanes requiring Lanes
765 --
766 -- TBD: We could also have the C level expose 'string.gmatch' for us. But this is simpler.
767 --
768 if not string then
769 error("To use 'lanes', you will also need to have 'string' available.", 2)
770 end
771
772 -- now we can configure Lanes core 769 -- now we can configure Lanes core
773 local settings = core.configure and core.configure(params_checker(settings_)) or core.settings 770 local settings = core.configure and core.configure(params_checker(settings_)) or core.settings
774 771