From a6f76ba28d7e7e9d2d277a85dfd054cb70c02b69 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Mon, 22 Jul 2013 09:27:23 +0200 Subject: wrap LuaJIT memory allocator in a critical section by default --- src/lanes.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lanes.lua b/src/lanes.lua index c02281d..ac3da26 100644 --- a/src/lanes.lua +++ b/src/lanes.lua @@ -62,7 +62,16 @@ lanes.configure = function( _params) local tostring = assert( tostring) local error = assert( error) - local default_params = { nb_keepers = 1, on_state_create = nil, shutdown_timeout = 0.25, with_timers = true, track_lanes = nil, protect_allocator = false} + local default_params = + { + nb_keepers = 1, + on_state_create = nil, + shutdown_timeout = 0.25, + with_timers = true, + track_lanes = nil, + -- LuaJIT provides a thread-unsafe allocator by default, so we need to protect it when used in parallel lanes + protect_allocator = (jit and jit.version) and true or false + } local param_checkers = { nb_keepers = function( _val) -- cgit v1.2.3-55-g6feb