aboutsummaryrefslogtreecommitdiff
path: root/src/linda.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/linda.cpp')
-rw-r--r--src/linda.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/linda.cpp b/src/linda.cpp
index b623d29..bd3026d 100644
--- a/src/linda.cpp
+++ b/src/linda.cpp
@@ -43,7 +43,7 @@ THE SOFTWARE.
43static void check_key_types(lua_State* L_, int start_, int end_) 43static void check_key_types(lua_State* L_, int start_, int end_)
44{ 44{
45 for (int _i{ start_ }; _i <= end_; ++_i) { 45 for (int _i{ start_ }; _i <= end_; ++_i) {
46 LuaType const t{ lua_type_as_enum(L_, _i) }; 46 LuaType const t{ luaG_type(L_, _i) };
47 switch (t) { 47 switch (t) {
48 case LuaType::BOOLEAN: 48 case LuaType::BOOLEAN:
49 case LuaType::NUMBER: 49 case LuaType::NUMBER:
@@ -79,10 +79,10 @@ template <bool OPT>
79{ 79{
80 Linda* const _linda{ ToLinda<OPT>(L_, idx_) }; 80 Linda* const _linda{ ToLinda<OPT>(L_, idx_) };
81 if (_linda != nullptr) { 81 if (_linda != nullptr) {
82 std::ignore = lua_pushstringview(L_, "Linda: "); 82 std::ignore = luaG_pushstringview(L_, "Linda: ");
83 std::string_view const _lindaName{ _linda->getName() }; 83 std::string_view const _lindaName{ _linda->getName() };
84 if (!_lindaName.empty()) { 84 if (!_lindaName.empty()) {
85 std::ignore = lua_pushstringview(L_, _lindaName); 85 std::ignore = luaG_pushstringview(L_, _lindaName);
86 } else { 86 } else {
87 lua_pushfstring(L_, "%p", _linda); 87 lua_pushfstring(L_, "%p", _linda);
88 } 88 }
@@ -247,7 +247,7 @@ void Linda::setName(std::string_view const& name_)
247LUAG_FUNC(linda_cancel) 247LUAG_FUNC(linda_cancel)
248{ 248{
249 Linda* const _linda{ ToLinda<false>(L_, 1) }; 249 Linda* const _linda{ ToLinda<false>(L_, 1) };
250 std::string_view const _who{ luaL_optstringview(L_, 2, "both") }; 250 std::string_view const _who{ luaG_optstringview(L_, 2, "both") };
251 // make sure we got 2 arguments: the linda and the cancellation mode 251 // make sure we got 2 arguments: the linda and the cancellation mode
252 luaL_argcheck(L_, lua_gettop(L_) <= 2, 2, "wrong number of arguments"); 252 luaL_argcheck(L_, lua_gettop(L_) <= 2, 2, "wrong number of arguments");
253 253
@@ -412,7 +412,7 @@ LUAG_FUNC(linda_limit)
412 _pushed = keeper_call(_K->L, KEEPER_API(limit), L_, _linda, 2); 412 _pushed = keeper_call(_K->L, KEEPER_API(limit), L_, _linda, 2);
413 LUA_ASSERT(L_, _pushed.has_value() && (_pushed.value() == 0 || _pushed.value() == 1)); // no error, optional boolean value saying if we should wake blocked writer threads 413 LUA_ASSERT(L_, _pushed.has_value() && (_pushed.value() == 0 || _pushed.value() == 1)); // no error, optional boolean value saying if we should wake blocked writer threads
414 if (_pushed.value() == 1) { 414 if (_pushed.value() == 1) {
415 LUA_ASSERT(L_, lua_type(L_, -1) == LUA_TBOOLEAN && lua_toboolean(L_, -1) == 1); 415 LUA_ASSERT(L_, luaG_type(L_, -1) == LuaType::BOOLEAN && lua_toboolean(L_, -1) == 1);
416 _linda->readHappened.notify_all(); // To be done from within the 'K' locking area 416 _linda->readHappened.notify_all(); // To be done from within the 'K' locking area
417 } 417 }
418 } else { // linda is cancelled 418 } else { // linda is cancelled
@@ -446,7 +446,7 @@ LUAG_FUNC(linda_receive)
446 int _key_i{ 2 }; // index of first key, if timeout not there 446 int _key_i{ 2 }; // index of first key, if timeout not there
447 447
448 std::chrono::time_point<std::chrono::steady_clock> _until{ std::chrono::time_point<std::chrono::steady_clock>::max() }; 448 std::chrono::time_point<std::chrono::steady_clock> _until{ std::chrono::time_point<std::chrono::steady_clock>::max() };
449 if (lua_type(L_, 2) == LUA_TNUMBER) { // we don't want to use lua_isnumber() because of autocoercion 449 if (luaG_type(L_, 2) == LuaType::NUMBER) { // we don't want to use lua_isnumber() because of autocoercion
450 lua_Duration const _duration{ lua_tonumber(L_, 2) }; 450 lua_Duration const _duration{ lua_tonumber(L_, 2) };
451 if (_duration.count() >= 0.0) { 451 if (_duration.count() >= 0.0) {
452 _until = std::chrono::steady_clock::now() + std::chrono::duration_cast<std::chrono::steady_clock::duration>(_duration); 452 _until = std::chrono::steady_clock::now() + std::chrono::duration_cast<std::chrono::steady_clock::duration>(_duration);
@@ -559,7 +559,7 @@ LUAG_FUNC(linda_receive)
559 if (_nbPushed == 0) { 559 if (_nbPushed == 0) {
560 // not enough data in the linda slot to fulfill the request, return nil, "timeout" 560 // not enough data in the linda slot to fulfill the request, return nil, "timeout"
561 lua_pushnil(L_); 561 lua_pushnil(L_);
562 std::ignore = lua_pushstringview(L_, "timeout"); 562 std::ignore = luaG_pushstringview(L_, "timeout");
563 return 2; 563 return 2;
564 } 564 }
565 return _nbPushed; 565 return _nbPushed;
@@ -600,7 +600,7 @@ LUAG_FUNC(linda_send)
600 int _key_i{ 2 }; // index of first key, if timeout not there 600 int _key_i{ 2 }; // index of first key, if timeout not there
601 601
602 std::chrono::time_point<std::chrono::steady_clock> _until{ std::chrono::time_point<std::chrono::steady_clock>::max() }; 602 std::chrono::time_point<std::chrono::steady_clock> _until{ std::chrono::time_point<std::chrono::steady_clock>::max() };
603 if (lua_type(L_, 2) == LUA_TNUMBER) { // we don't want to use lua_isnumber() because of autocoercion 603 if (luaG_type(L_, 2) == LuaType::NUMBER) { // we don't want to use lua_isnumber() because of autocoercion
604 lua_Duration const _duration{ lua_tonumber(L_, 2) }; 604 lua_Duration const _duration{ lua_tonumber(L_, 2) };
605 if (_duration.count() >= 0.0) { 605 if (_duration.count() >= 0.0) {
606 _until = std::chrono::steady_clock::now() + std::chrono::duration_cast<std::chrono::steady_clock::duration>(_duration); 606 _until = std::chrono::steady_clock::now() + std::chrono::duration_cast<std::chrono::steady_clock::duration>(_duration);
@@ -742,7 +742,7 @@ LUAG_FUNC(linda_set)
742 } 742 }
743 if (_pushed.value() == 1) { 743 if (_pushed.value() == 1) {
744 // the key was full, but it is no longer the case, tell writers they should wake 744 // the key was full, but it is no longer the case, tell writers they should wake
745 LUA_ASSERT(L_, lua_type(L_, -1) == LUA_TBOOLEAN && lua_toboolean(L_, -1) == 1); 745 LUA_ASSERT(L_, luaG_type(L_, -1) == LuaType::BOOLEAN && lua_toboolean(L_, -1) == 1);
746 _linda->readHappened.notify_all(); // To be done from within the 'K' locking area 746 _linda->readHappened.notify_all(); // To be done from within the 'K' locking area
747 } 747 }
748 } 748 }
@@ -826,7 +826,7 @@ LUAG_FUNC(linda)
826 int _groupIdx{}; 826 int _groupIdx{};
827 luaL_argcheck(L_, _top <= 2, _top, "too many arguments"); 827 luaL_argcheck(L_, _top <= 2, _top, "too many arguments");
828 if (_top == 1) { 828 if (_top == 1) {
829 LuaType const _t{ lua_type_as_enum(L_, 1) }; 829 LuaType const _t{ luaG_type(L_, 1) };
830 int const _nameIdx{ (_t == LuaType::STRING) ? 1 : 0 }; 830 int const _nameIdx{ (_t == LuaType::STRING) ? 1 : 0 };
831 _groupIdx = (_t == LuaType::NUMBER) ? 1 : 0; 831 _groupIdx = (_t == LuaType::NUMBER) ? 1 : 0;
832 luaL_argcheck(L_, _nameIdx || _groupIdx, 1, "wrong parameter (should be a string or a number)"); 832 luaL_argcheck(L_, _nameIdx || _groupIdx, 1, "wrong parameter (should be a string or a number)");