diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-05-30 17:57:21 +0200 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-05-30 17:57:21 +0200 |
commit | 731556711e453a501f1d1d06a6013b8fbd53414e (patch) | |
tree | 4c5c28cd83de320fcf4c9b4c749f2e6e8d5bef48 /src/lanes.lua | |
parent | a156aaeb07fada043b308409dcffcae1726eec0b (diff) | |
download | lanes-731556711e453a501f1d1d06a6013b8fbd53414e.tar.gz lanes-731556711e453a501f1d1d06a6013b8fbd53414e.tar.bz2 lanes-731556711e453a501f1d1d06a6013b8fbd53414e.zip |
Keeper management modernisation and improvements
* use a std::variant to manage the distinction between one or more keeper states. Use std::unique_ptr<Keeper[]> to manage the multiple keeper case.
* setting "nb_keepers" renamed "nb_user_keepers", to indicate these are in addition to internal keeper #0 used for timers.
* stricter lanes.linda() argument checking. group is imposed if more than one keeper is used.
* more tests
Diffstat (limited to 'src/lanes.lua')
-rw-r--r-- | src/lanes.lua | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/lanes.lua b/src/lanes.lua index e7763b1..1c36b46 100644 --- a/src/lanes.lua +++ b/src/lanes.lua | |||
@@ -90,7 +90,7 @@ 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_keepers = 1, | 93 | nb_user_keepers = 0, |
94 | keepers_gc_threshold = -1, | 94 | keepers_gc_threshold = -1, |
95 | on_state_create = nil, | 95 | on_state_create = nil, |
96 | shutdown_timeout = 0.25, | 96 | shutdown_timeout = 0.25, |
@@ -114,9 +114,9 @@ end | |||
114 | 114 | ||
115 | local param_checkers = | 115 | local param_checkers = |
116 | { | 116 | { |
117 | nb_keepers = function(val_) | 117 | nb_user_keepers = function(val_) |
118 | -- nb_keepers should be a number in [1,100] (so that nobody tries to run OOM by specifying a huge amount) | 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 | 119 | return type(val_) == "number" and val_ >= 0 and val_ <= 100 |
120 | end, | 120 | end, |
121 | keepers_gc_threshold = function(val_) | 121 | keepers_gc_threshold = function(val_) |
122 | -- keepers_gc_threshold should be a number | 122 | -- keepers_gc_threshold should be a number |
@@ -176,7 +176,7 @@ local params_checker = function(settings_) | |||
176 | param = default_params[key] | 176 | param = default_params[key] |
177 | end | 177 | end |
178 | if not checker(param) then | 178 | if not checker(param) then |
179 | error("Bad " .. key .. ": " .. tostring(param), 2) | 179 | error("Bad parameter " .. key .. ": " .. tostring(param), 2) |
180 | end | 180 | end |
181 | settings[key] = param | 181 | settings[key] = param |
182 | end | 182 | end |