diff options
Diffstat (limited to 'src/linda.cpp')
-rw-r--r-- | src/linda.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/linda.cpp b/src/linda.cpp index 7b3973d..4635d75 100644 --- a/src/linda.cpp +++ b/src/linda.cpp | |||
@@ -168,7 +168,7 @@ template <bool OPT> | |||
168 | if constexpr (!OPT) | 168 | if constexpr (!OPT) |
169 | { | 169 | { |
170 | luaL_argcheck(L, linda != nullptr, idx_, "expecting a linda object"); | 170 | luaL_argcheck(L, linda != nullptr, idx_, "expecting a linda object"); |
171 | ASSERT_L(linda->U == universe_get(L)); | 171 | LUA_ASSERT(L, linda->U == universe_get(L)); |
172 | } | 172 | } |
173 | return linda; | 173 | return linda; |
174 | } | 174 | } |
@@ -218,7 +218,7 @@ int Linda::ProtectedCall(lua_State* L, lua_CFunction f_) | |||
218 | if (KL == nullptr) | 218 | if (KL == nullptr) |
219 | return 0; | 219 | return 0; |
220 | // if we didn't do anything wrong, the keeper stack should be clean | 220 | // if we didn't do anything wrong, the keeper stack should be clean |
221 | ASSERT_L(lua_gettop(KL) == 0); | 221 | LUA_ASSERT(L, lua_gettop(KL) == 0); |
222 | 222 | ||
223 | // push the function to be called and move it before the arguments | 223 | // push the function to be called and move it before the arguments |
224 | lua_pushcfunction(L, f_); | 224 | lua_pushcfunction(L, f_); |
@@ -332,7 +332,7 @@ LUAG_FUNC(linda_send) | |||
332 | { | 332 | { |
333 | break; | 333 | break; |
334 | } | 334 | } |
335 | ASSERT_L(pushed.value() == 1); | 335 | LUA_ASSERT(L, pushed.value() == 1); |
336 | 336 | ||
337 | ret = lua_toboolean(L, -1) ? true : false; | 337 | ret = lua_toboolean(L, -1) ? true : false; |
338 | lua_pop(L, 1); | 338 | lua_pop(L, 1); |
@@ -357,9 +357,9 @@ LUAG_FUNC(linda_send) | |||
357 | { | 357 | { |
358 | // change status of lane to "waiting" | 358 | // change status of lane to "waiting" |
359 | prev_status = lane->m_status; // Running, most likely | 359 | prev_status = lane->m_status; // Running, most likely |
360 | ASSERT_L(prev_status == Lane::Running); // but check, just in case | 360 | LUA_ASSERT(L, prev_status == Lane::Running); // but check, just in case |
361 | lane->m_status = Lane::Waiting; | 361 | lane->m_status = Lane::Waiting; |
362 | ASSERT_L(lane->m_waiting_on == nullptr); | 362 | LUA_ASSERT(L, lane->m_waiting_on == nullptr); |
363 | lane->m_waiting_on = &linda->m_read_happened; | 363 | lane->m_waiting_on = &linda->m_read_happened; |
364 | } | 364 | } |
365 | // could not send because no room: wait until some data was read before trying again, or until timeout is reached | 365 | // could not send because no room: wait until some data was read before trying again, or until timeout is reached |
@@ -502,7 +502,7 @@ LUAG_FUNC(linda_receive) | |||
502 | } | 502 | } |
503 | if (pushed.value() > 0) | 503 | if (pushed.value() > 0) |
504 | { | 504 | { |
505 | ASSERT_L(pushed.value() >= expected_pushed_min && pushed.value() <= expected_pushed_max); | 505 | LUA_ASSERT(L, pushed.value() >= expected_pushed_min && pushed.value() <= expected_pushed_max); |
506 | // replace sentinels with real nils | 506 | // replace sentinels with real nils |
507 | keeper_toggle_nil_sentinels(L, lua_gettop(L) - pushed.value(), LookupMode::FromKeeper); | 507 | keeper_toggle_nil_sentinels(L, lua_gettop(L) - pushed.value(), LookupMode::FromKeeper); |
508 | // To be done from within the 'K' locking area | 508 | // To be done from within the 'K' locking area |
@@ -523,9 +523,9 @@ LUAG_FUNC(linda_receive) | |||
523 | { | 523 | { |
524 | // change status of lane to "waiting" | 524 | // change status of lane to "waiting" |
525 | prev_status = lane->m_status; // Running, most likely | 525 | prev_status = lane->m_status; // Running, most likely |
526 | ASSERT_L(prev_status == Lane::Running); // but check, just in case | 526 | LUA_ASSERT(L, prev_status == Lane::Running); // but check, just in case |
527 | lane->m_status = Lane::Waiting; | 527 | lane->m_status = Lane::Waiting; |
528 | ASSERT_L(lane->m_waiting_on == nullptr); | 528 | LUA_ASSERT(L, lane->m_waiting_on == nullptr); |
529 | lane->m_waiting_on = &linda->m_write_happened; | 529 | lane->m_waiting_on = &linda->m_write_happened; |
530 | } | 530 | } |
531 | // not enough data to read: wakeup when data was sent, or when timeout is reached | 531 | // not enough data to read: wakeup when data was sent, or when timeout is reached |
@@ -596,7 +596,7 @@ LUAG_FUNC(linda_set) | |||
596 | pushed = keeper_call(linda->U, K->L, KEEPER_API(set), L, linda, 2); | 596 | pushed = keeper_call(linda->U, K->L, KEEPER_API(set), L, linda, 2); |
597 | if (pushed.has_value()) // no error? | 597 | if (pushed.has_value()) // no error? |
598 | { | 598 | { |
599 | ASSERT_L(pushed.value() == 0 || pushed.value() == 1); | 599 | LUA_ASSERT(L, pushed.value() == 0 || pushed.value() == 1); |
600 | 600 | ||
601 | if (has_value) | 601 | if (has_value) |
602 | { | 602 | { |
@@ -606,7 +606,7 @@ LUAG_FUNC(linda_set) | |||
606 | if (pushed.value() == 1) | 606 | if (pushed.value() == 1) |
607 | { | 607 | { |
608 | // the key was full, but it is no longer the case, tell writers they should wake | 608 | // the key was full, but it is no longer the case, tell writers they should wake |
609 | ASSERT_L(lua_type(L, -1) == LUA_TBOOLEAN && lua_toboolean(L, -1) == 1); | 609 | LUA_ASSERT(L, lua_type(L, -1) == LUA_TBOOLEAN && lua_toboolean(L, -1) == 1); |
610 | linda->m_read_happened.notify_all(); // To be done from within the 'K' locking area | 610 | linda->m_read_happened.notify_all(); // To be done from within the 'K' locking area |
611 | } | 611 | } |
612 | } | 612 | } |
@@ -711,10 +711,10 @@ LUAG_FUNC(linda_limit) | |||
711 | { | 711 | { |
712 | Keeper* const K{ which_keeper(linda->U->keepers, linda->hashSeed()) }; | 712 | Keeper* const K{ which_keeper(linda->U->keepers, linda->hashSeed()) }; |
713 | pushed = keeper_call(linda->U, K->L, KEEPER_API(limit), L, linda, 2); | 713 | pushed = keeper_call(linda->U, K->L, KEEPER_API(limit), L, linda, 2); |
714 | ASSERT_L( pushed.has_value() && (pushed.value() == 0 || pushed.value() == 1)); // no error, optional boolean value saying if we should wake blocked writer threads | 714 | 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 |
715 | if (pushed.value() == 1) | 715 | if (pushed.value() == 1) |
716 | { | 716 | { |
717 | ASSERT_L( lua_type( L, -1) == LUA_TBOOLEAN && lua_toboolean( L, -1) == 1); | 717 | LUA_ASSERT(L, lua_type( L, -1) == LUA_TBOOLEAN && lua_toboolean( L, -1) == 1); |
718 | linda->m_read_happened.notify_all(); // To be done from within the 'K' locking area | 718 | linda->m_read_happened.notify_all(); // To be done from within the 'K' locking area |
719 | } | 719 | } |
720 | } | 720 | } |
@@ -931,7 +931,7 @@ DeepPrelude* LindaFactory::newDeepObjectInternal(lua_State* L) const | |||
931 | void LindaFactory::deleteDeepObjectInternal(lua_State* L, DeepPrelude* o_) const | 931 | void LindaFactory::deleteDeepObjectInternal(lua_State* L, DeepPrelude* o_) const |
932 | { | 932 | { |
933 | Linda* const linda{ static_cast<Linda*>(o_) }; | 933 | Linda* const linda{ static_cast<Linda*>(o_) }; |
934 | ASSERT_L(linda); | 934 | LUA_ASSERT(L, linda); |
935 | Keeper* const myK{ which_keeper(linda->U->keepers, linda->hashSeed()) }; | 935 | Keeper* const myK{ which_keeper(linda->U->keepers, linda->hashSeed()) }; |
936 | // if collected after the universe, keepers are already destroyed, and there is nothing to clear | 936 | // if collected after the universe, keepers are already destroyed, and there is nothing to clear |
937 | if (myK) | 937 | if (myK) |
@@ -943,7 +943,7 @@ void LindaFactory::deleteDeepObjectInternal(lua_State* L, DeepPrelude* o_) const | |||
943 | Keeper* const K{ need_acquire_release ? keeper_acquire(linda->U->keepers, linda->hashSeed()) : myK }; | 943 | Keeper* const K{ need_acquire_release ? keeper_acquire(linda->U->keepers, linda->hashSeed()) : myK }; |
944 | // hopefully this won't ever raise an error as we would jump to the closest pcall site while forgetting to release the keeper mutex... | 944 | // hopefully this won't ever raise an error as we would jump to the closest pcall site while forgetting to release the keeper mutex... |
945 | [[maybe_unused]] KeeperCallResult const result{ keeper_call(linda->U, K->L, KEEPER_API(clear), L, linda, 0) }; | 945 | [[maybe_unused]] KeeperCallResult const result{ keeper_call(linda->U, K->L, KEEPER_API(clear), L, linda, 0) }; |
946 | ASSERT_L(result.has_value() && result.value() == 0); | 946 | LUA_ASSERT(L, result.has_value() && result.value() == 0); |
947 | if (need_acquire_release) | 947 | if (need_acquire_release) |
948 | { | 948 | { |
949 | keeper_release(K); | 949 | keeper_release(K); |