diff options
author | Benoit Germain <bnt period germain arrobase gmail period com> | 2013-12-20 11:46:42 +0100 |
---|---|---|
committer | Benoit Germain <bnt period germain arrobase gmail period com> | 2013-12-20 11:46:42 +0100 |
commit | 4ece73b1e0d8f75fa63a5b39a91731147870bd0a (patch) | |
tree | 7b55c53524805988be95b7ecd34f3df0aa33ab23 /src/lanes.lua | |
parent | bfe766927eeced475904acdc08c0ec5375e5ab49 (diff) | |
download | lanes-4ece73b1e0d8f75fa63a5b39a91731147870bd0a.tar.gz lanes-4ece73b1e0d8f75fa63a5b39a91731147870bd0a.tar.bz2 lanes-4ece73b1e0d8f75fa63a5b39a91731147870bd0a.zip |
new config option demote_full_userdata
use demote_full_userdata to select between light userdata demotion or
raising an error when attempting to transfer a non-deep full userdata
Diffstat (limited to 'src/lanes.lua')
-rw-r--r-- | src/lanes.lua | 50 |
1 files changed, 16 insertions, 34 deletions
diff --git a/src/lanes.lua b/src/lanes.lua index 6e2a736..4856a2d 100644 --- a/src/lanes.lua +++ b/src/lanes.lua | |||
@@ -71,52 +71,34 @@ lanes.configure = function( settings_) | |||
71 | shutdown_timeout = 0.25, | 71 | shutdown_timeout = 0.25, |
72 | with_timers = true, | 72 | with_timers = true, |
73 | track_lanes = false, | 73 | track_lanes = false, |
74 | demote_full_userdata = nil, | ||
74 | verbose_errors = false, | 75 | verbose_errors = false, |
75 | -- LuaJIT provides a thread-unsafe allocator by default, so we need to protect it when used in parallel lanes | 76 | -- LuaJIT provides a thread-unsafe allocator by default, so we need to protect it when used in parallel lanes |
76 | protect_allocator = (jit and jit.version) and true or false | 77 | protect_allocator = (jit and jit.version) and true or false |
77 | } | 78 | } |
79 | local boolean_param_checker = function( val_) | ||
80 | -- non-'boolean-false' should be 'boolean-true' or nil | ||
81 | return val_ and (val_ == true) or true | ||
82 | end | ||
78 | local param_checkers = | 83 | local param_checkers = |
79 | { | 84 | { |
80 | nb_keepers = function( _val) | 85 | nb_keepers = function( val_) |
81 | -- nb_keepers should be a number > 0 | 86 | -- nb_keepers should be a number > 0 |
82 | return type( _val) == "number" and _val > 0 | 87 | return type( val_) == "number" and val_ > 0 |
83 | end, | ||
84 | with_timers = function( _val) | ||
85 | -- with_timers may be nil or boolean | ||
86 | if _val then | ||
87 | return type( _val) == "boolean" | ||
88 | else | ||
89 | return true -- _val is either false or nil | ||
90 | end | ||
91 | end, | 88 | end, |
92 | protect_allocator = function( _val) | 89 | with_timers = boolean_param_checker, |
93 | -- protect_allocator may be nil or boolean | 90 | protect_allocator = boolean_param_checker, |
94 | if _val then | 91 | on_state_create = function( val_) |
95 | return type( _val) == "boolean" | ||
96 | else | ||
97 | return true -- _val is either false or nil | ||
98 | end | ||
99 | end, | ||
100 | on_state_create = function( _val) | ||
101 | -- on_state_create may be nil or a function | 92 | -- on_state_create may be nil or a function |
102 | return _val and type( _val) == "function" or true | 93 | return val_ and type( val_) == "function" or true |
103 | end, | 94 | end, |
104 | shutdown_timeout = function( _val) | 95 | shutdown_timeout = function( val_) |
105 | -- shutdown_timeout should be a number >= 0 | 96 | -- shutdown_timeout should be a number >= 0 |
106 | return type( _val) == "number" and _val >= 0 | 97 | return type( val_) == "number" and val_ >= 0 |
107 | end, | ||
108 | track_lanes = function( _val) | ||
109 | -- track_lanes may be nil or boolean | ||
110 | return _val and type( _val) == "boolean" or true | ||
111 | end, | 98 | end, |
112 | verbose_errors = function( _val) | 99 | track_lanes = boolean_param_checker, |
113 | -- verbose_errors may be nil or boolean | 100 | demote_full_userdata = boolean_param_checker, |
114 | if _val then | 101 | verbose_errors = boolean_param_checker |
115 | return type( _val) == "boolean" | ||
116 | else | ||
117 | return true -- _val is either false or nil | ||
118 | end | ||
119 | end | ||
120 | } | 102 | } |
121 | 103 | ||
122 | local params_checker = function( settings_) | 104 | local params_checker = function( settings_) |