aboutsummaryrefslogtreecommitdiff
path: root/src/linda.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/linda.cpp')
-rw-r--r--src/linda.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/linda.cpp b/src/linda.cpp
index 76607a4..48da1cf 100644
--- a/src/linda.cpp
+++ b/src/linda.cpp
@@ -354,21 +354,22 @@ LUAG_FUNC(linda_get)
354// ################################################################################################# 354// #################################################################################################
355 355
356/* 356/*
357 * [true] = linda_limit( linda_ud, key_num|str|bool|lightuserdata, int) 357 * [true] = linda_limit( linda_ud, key_num|str|bool|lightuserdata, [int])
358 * 358 *
359 * Set limit to 1 Linda keys. 359 * Set limit to 1 Linda keys.
360 * Optionally wake threads waiting to write on the linda, in case the limit enables them to do so 360 * Optionally wake threads waiting to write on the linda, in case the limit enables them to do so
361 * Limit can be 0 to completely block everything 361 * Limit can be 0 to completely block everything, nil to reset
362 */ 362 */
363LUAG_FUNC(linda_limit) 363LUAG_FUNC(linda_limit)
364{ 364{
365 auto _limit = [](lua_State* L_) { 365 auto _limit = [](lua_State* L_) {
366 Linda* const _linda{ ToLinda<false>(L_, 1) }; 366 Linda* const _linda{ ToLinda<false>(L_, 1) };
367 // make sure we got 3 arguments: the linda, a key and a limit 367 // make sure we got 3 arguments: the linda, a key and a limit
368 luaL_argcheck(L_, lua_gettop(L_) == 3, 2, "wrong number of arguments"); 368 int const _nargs{ lua_gettop(L_) };
369 luaL_argcheck(L_, _nargs == 2 || _nargs == 3, 2, "wrong number of arguments");
369 // make sure we got a numeric limit 370 // make sure we got a numeric limit
370 lua_Number const _limit{ luaL_checknumber(L_, 3) }; 371 lua_Integer const _limit{ luaL_optinteger(L_, 3, 0) };
371 if (_limit < 1) { 372 if (_limit < 0) {
372 raise_luaL_argerror(L_, 3, "limit must be >= 0"); 373 raise_luaL_argerror(L_, 3, "limit must be >= 0");
373 } 374 }
374 // make sure the key is of a valid type 375 // make sure the key is of a valid type