diff options
Diffstat (limited to '')
-rw-r--r-- | src/lanes.lua | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/src/lanes.lua b/src/lanes.lua index 4f11033..95c4eff 100644 --- a/src/lanes.lua +++ b/src/lanes.lua | |||
@@ -90,19 +90,20 @@ local isLuaJIT = (package and package.loaded.jit and jit.version) and true or fa | |||
90 | 90 | ||
91 | local default_params = | 91 | local default_params = |
92 | { | 92 | { |
93 | nb_user_keepers = 0, | 93 | -- LuaJIT provides a thread-unsafe allocator by default, so we need to protect it when used in parallel lanes |
94 | allocator = isLuaJIT and "protected" or nil, | ||
95 | demote_full_userdata = nil, | ||
96 | -- 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", | ||
94 | keepers_gc_threshold = -1, | 98 | keepers_gc_threshold = -1, |
99 | nb_user_keepers = 0, | ||
95 | on_state_create = nil, | 100 | on_state_create = nil, |
96 | shutdown_timeout = 0.25, | ||
97 | shutdown_mode = "hard", | 101 | shutdown_mode = "hard", |
98 | with_timers = false, | 102 | shutdown_timeout = 0.25, |
103 | strip_functions = true, | ||
99 | track_lanes = false, | 104 | track_lanes = false, |
100 | demote_full_userdata = nil, | ||
101 | verbose_errors = false, | 105 | verbose_errors = false, |
102 | -- LuaJIT provides a thread-unsafe allocator by default, so we need to protect it when used in parallel lanes | 106 | with_timers = false, |
103 | allocator = isLuaJIT and "protected" or nil, | ||
104 | -- it looks also like LuaJIT allocator may not appreciate direct use of its allocator for other purposes than the VM operation | ||
105 | internal_allocator = isLuaJIT and "libc" or "allocator" | ||
106 | } | 107 | } |
107 | 108 | ||
108 | -- ################################################################################################# | 109 | -- ################################################################################################# |
@@ -114,39 +115,40 @@ end | |||
114 | 115 | ||
115 | local param_checkers = | 116 | local param_checkers = |
116 | { | 117 | { |
117 | nb_user_keepers = function(val_) | ||
118 | -- nb_user_keepers should be a number in [0,100] (so that nobody tries to run OOM by specifying a huge amount) | ||
119 | return type(val_) == "number" and val_ >= 0 and val_ <= 100 | ||
120 | end, | ||
121 | keepers_gc_threshold = function(val_) | ||
122 | -- keepers_gc_threshold should be a number | ||
123 | return type(val_) == "number" | ||
124 | end, | ||
125 | with_timers = boolean_param_checker, | ||
126 | allocator = function(val_) | 118 | allocator = function(val_) |
127 | -- can be nil, "protected", or a function | 119 | -- can be nil, "protected", or a function |
128 | return val_ and (type(val_) == "function" or val_ == "protected") or true | 120 | return val_ and (type(val_) == "function" or val_ == "protected") or true |
129 | end, | 121 | end, |
122 | demote_full_userdata = boolean_param_checker, | ||
130 | internal_allocator = function(val_) | 123 | internal_allocator = function(val_) |
131 | -- can be "libc" or "allocator" | 124 | -- can be "libc" or "allocator" |
132 | return val_ == "libc" or val_ == "allocator" | 125 | return val_ == "libc" or val_ == "allocator" |
133 | end, | 126 | end, |
127 | keepers_gc_threshold = function(val_) | ||
128 | -- keepers_gc_threshold should be a number | ||
129 | return type(val_) == "number" | ||
130 | end, | ||
131 | nb_user_keepers = function(val_) | ||
132 | -- nb_user_keepers should be a number in [0,100] (so that nobody tries to run OOM by specifying a huge amount) | ||
133 | return type(val_) == "number" and val_ >= 0 and val_ <= 100 | ||
134 | end, | ||
134 | on_state_create = function(val_) | 135 | on_state_create = function(val_) |
135 | -- on_state_create may be nil or a function | 136 | -- on_state_create may be nil or a function |
136 | return val_ and type(val_) == "function" or true | 137 | return val_ and type(val_) == "function" or true |
137 | end, | 138 | end, |
138 | shutdown_timeout = function(val_) | ||
139 | -- shutdown_timeout should be a number >= 0 | ||
140 | return type(val_) == "number" and val_ >= 0 | ||
141 | end, | ||
142 | shutdown_mode = function(val_) | 139 | shutdown_mode = function(val_) |
143 | local valid_hooks = { soft = true, hard = true, call = true, ret = true, line = true, count = true } | 140 | local valid_hooks = { soft = true, hard = true, call = true, ret = true, line = true, count = true } |
144 | -- shutdown_mode should be a known hook mask | 141 | -- shutdown_mode should be a known hook mask |
145 | return valid_hooks[val_] | 142 | return valid_hooks[val_] |
146 | end, | 143 | end, |
144 | shutdown_timeout = function(val_) | ||
145 | -- shutdown_timeout should be a number >= 0 | ||
146 | return type(val_) == "number" and val_ >= 0 | ||
147 | end, | ||
148 | strip_functions = boolean_param_checker, | ||
147 | track_lanes = boolean_param_checker, | 149 | track_lanes = boolean_param_checker, |
148 | demote_full_userdata = boolean_param_checker, | 150 | verbose_errors = boolean_param_checker, |
149 | verbose_errors = boolean_param_checker | 151 | with_timers = boolean_param_checker, |
150 | } | 152 | } |
151 | 153 | ||
152 | -- ################################################################################################# | 154 | -- ################################################################################################# |