diff options
Diffstat (limited to 'src/lanes.lua')
-rw-r--r-- | src/lanes.lua | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/lanes.lua b/src/lanes.lua index 85d8e58..ff5fdf3 100644 --- a/src/lanes.lua +++ b/src/lanes.lua | |||
@@ -65,6 +65,8 @@ local type = assert(type) | |||
65 | 65 | ||
66 | -- ################################################################################################# | 66 | -- ################################################################################################# |
67 | 67 | ||
68 | local isLuaJIT = (package and package.loaded.jit and jit.version) and true or false | ||
69 | |||
68 | local default_params = | 70 | local default_params = |
69 | { | 71 | { |
70 | nb_keepers = 1, | 72 | nb_keepers = 1, |
@@ -77,9 +79,9 @@ local default_params = | |||
77 | demote_full_userdata = nil, | 79 | demote_full_userdata = nil, |
78 | verbose_errors = false, | 80 | verbose_errors = false, |
79 | -- LuaJIT provides a thread-unsafe allocator by default, so we need to protect it when used in parallel lanes | 81 | -- LuaJIT provides a thread-unsafe allocator by default, so we need to protect it when used in parallel lanes |
80 | allocator = (package and package.loaded.jit and jit.version) and "protected" or nil, | 82 | allocator = isLuaJIT and "protected" or nil, |
81 | -- it looks also like LuaJIT allocator may not appreciate direct use of its allocator for other purposes than the VM operation | 83 | -- it looks also like LuaJIT allocator may not appreciate direct use of its allocator for other purposes than the VM operation |
82 | internal_allocator = (package and package.loaded.jit and jit.version) and "libc" or "allocator" | 84 | internal_allocator = isLuaJIT and "libc" or "allocator" |
83 | } | 85 | } |
84 | 86 | ||
85 | -- ################################################################################################# | 87 | -- ################################################################################################# |
@@ -207,12 +209,23 @@ end | |||
207 | 209 | ||
208 | -- ################################################################################################# | 210 | -- ################################################################################################# |
209 | 211 | ||
212 | -- must match Lane::ErrorTraceLevel values | ||
213 | local error_trace_levels = { | ||
214 | minimal = 0, | ||
215 | basic = 1, | ||
216 | extended = 2 | ||
217 | } | ||
218 | |||
210 | local opt_validators = | 219 | local opt_validators = |
211 | { | 220 | { |
212 | gc_cb = function(v_) | 221 | gc_cb = function(v_) |
213 | local tv = type(v_) | 222 | local tv = type(v_) |
214 | return (tv == "function") and v_ or raise_option_error("gc_cb", tv, v_) | 223 | return (tv == "function") and v_ or raise_option_error("gc_cb", tv, v_) |
215 | end, | 224 | end, |
225 | error_trace_level = function(v_) | ||
226 | local tv = type(v_) | ||
227 | return (error_trace_levels[v_] ~= nil) and v_ or raise_option_error("error_trace_level", tv, v_) | ||
228 | end, | ||
216 | globals = function(v_) | 229 | globals = function(v_) |
217 | local tv = type(v_) | 230 | local tv = type(v_) |
218 | return (tv == "table") and v_ or raise_option_error("globals", tv, v_) | 231 | return (tv == "table") and v_ or raise_option_error("globals", tv, v_) |
@@ -343,10 +356,10 @@ local gen = function(...) | |||
343 | end | 356 | end |
344 | 357 | ||
345 | local core_lane_new = assert(core.lane_new) | 358 | local core_lane_new = assert(core.lane_new) |
346 | local priority, globals, package, required, gc_cb, name = opt.priority, opt.globals, opt.package or package, opt.required, opt.gc_cb, opt.name | 359 | local priority, globals, package, required, gc_cb, name, error_trace_level = opt.priority, opt.globals, opt.package or package, opt.required, opt.gc_cb, opt.name, error_trace_levels[opt.error_trace_level] |
347 | return function(...) | 360 | return function(...) |
348 | -- must pass functions args last else they will be truncated to the first one | 361 | -- must pass functions args last else they will be truncated to the first one |
349 | return core_lane_new(func, libs, priority, globals, package, required, gc_cb, name, ...) | 362 | return core_lane_new(func, libs, priority, globals, package, required, gc_cb, name, error_trace_level, ...) |
350 | end | 363 | end |
351 | end -- gen() | 364 | end -- gen() |
352 | 365 | ||