aboutsummaryrefslogtreecommitdiff
path: root/src/lanes.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/lanes.lua')
-rw-r--r--src/lanes.lua28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/lanes.lua b/src/lanes.lua
index c5b3315..43ebfd5 100644
--- a/src/lanes.lua
+++ b/src/lanes.lua
@@ -93,6 +93,8 @@ local default_params =
93{ 93{
94 -- LuaJIT provides a thread-unsafe allocator by default, so we need to protect it when used in parallel lanes 94 -- LuaJIT provides a thread-unsafe allocator by default, so we need to protect it when used in parallel lanes
95 allocator = isLuaJIT and "protected" or nil, 95 allocator = isLuaJIT and "protected" or nil,
96 convert_fallback = nil,
97 convert_max_attempts = 1,
96 -- it looks also like LuaJIT allocator may not appreciate direct use of its allocator for other purposes than the VM operation 98 -- it looks also like LuaJIT allocator may not appreciate direct use of its allocator for other purposes than the VM operation
97 internal_allocator = isLuaJIT and "libc" or "allocator", 99 internal_allocator = isLuaJIT and "libc" or "allocator",
98 keepers_gc_threshold = -1, 100 keepers_gc_threshold = -1,
@@ -125,6 +127,23 @@ local param_checkers =
125 end 127 end
126 return true 128 return true
127 end, 129 end,
130 convert_fallback = function(val_)
131 -- convert_fallback should be nil, lanes.null or 'decay'
132 if val_ == nil or val_ == core.null or val_ == 'decay' then
133 return true
134 end
135 return nil, "must be nil, lanes.null or 'decay'"
136 end, -- convert_fallback
137 convert_max_attempts = function(val_)
138 -- convert_max_attempts should be a number
139 if type(val_) ~= "number" then
140 return nil, "not a number"
141 end
142 if val_ <= 0 or val_ >= 10 then
143 return nil, "value out of range"
144 end
145 return true
146 end, -- convert_fallback
128 internal_allocator = function(val_) 147 internal_allocator = function(val_)
129 -- can be "libc" or "allocator" 148 -- can be "libc" or "allocator"
130 if type(val_) ~= "string" then 149 if type(val_) ~= "string" then
@@ -850,12 +869,8 @@ local configure = function(settings_)
850 lanes.configure = function() return lanes end -- no need to configure anything again 869 lanes.configure = function() return lanes end -- no need to configure anything again
851 870
852 -- now we can configure Lanes core 871 -- now we can configure Lanes core
853
854
855
856
857
858 local settings = core.configure and core.configure(params_checker(settings_)) or core.settings 872 local settings = core.configure and core.configure(params_checker(settings_)) or core.settings
873 assert(type(settings) == 'table')
859 874
860 -- 875 --
861 lanes.ABOUT = 876 lanes.ABOUT =
@@ -912,7 +927,10 @@ lanesMeta.__index = function(lanes_, k_)
912 -- Access the required key 927 -- Access the required key
913 return lanes_[k_] 928 return lanes_[k_]
914end 929end
930
915lanes.configure = configure 931lanes.configure = configure
932-- lanes.null can be used for some configure settings, expose it now
933lanes.null = assert(core.null)
916setmetatable(lanes, lanesMeta) 934setmetatable(lanes, lanesMeta)
917 935
918-- ################################################################################################# 936-- #################################################################################################