diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-12-10 17:07:09 +0100 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-12-10 17:07:09 +0100 |
commit | 18c708eb8fbe995efe4b06b93421db3d25e22636 (patch) | |
tree | 860a74b3a914dfacc9c959374ad4415a7f54873b /src/linda.cpp | |
parent | 5f9ef9e1b75adc27a4ae4129cc33137aa7aaa565 (diff) | |
download | lanes-18c708eb8fbe995efe4b06b93421db3d25e22636.tar.gz lanes-18c708eb8fbe995efe4b06b93421db3d25e22636.tar.bz2 lanes-18c708eb8fbe995efe4b06b93421db3d25e22636.zip |
lanes.collectgarbage() and linda:collectgarbage()
Diffstat (limited to 'src/linda.cpp')
-rw-r--r-- | src/linda.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/linda.cpp b/src/linda.cpp index 7af387f..4f33899 100644 --- a/src/linda.cpp +++ b/src/linda.cpp | |||
@@ -450,6 +450,29 @@ static LUAG_FUNC(linda_index) | |||
450 | // ################################################################################################# | 450 | // ################################################################################################# |
451 | 451 | ||
452 | /* | 452 | /* |
453 | * (void) = linda_collectgarbage( linda_ud) | ||
454 | * | ||
455 | * Force a GC cycle in the keeper assigned to the Linda | ||
456 | */ | ||
457 | LUAG_FUNC(linda_collectgarbage) | ||
458 | { | ||
459 | static constexpr lua_CFunction _collectgarbage{ | ||
460 | +[](lua_State* const L_) { | ||
461 | Linda* const _linda{ ToLinda<false>(L_, StackIndex{ 1 }) }; | ||
462 | if (lua_gettop(L_) > 1) { | ||
463 | raise_luaL_argerror(L_, StackIndex{ 2 }, "Unexpected extra argument"); | ||
464 | } | ||
465 | Keeper* const _keeper{ _linda->whichKeeper() }; | ||
466 | KeeperCallResult const _pushed{ keeper_call(_keeper->K, KEEPER_API(collectgarbage), L_, _linda, StackIndex{ 0 }) }; | ||
467 | return OptionalValue(_pushed, L_, "Unexpected error"); | ||
468 | } | ||
469 | }; | ||
470 | return Linda::ProtectedCall(L_, _collectgarbage); | ||
471 | } | ||
472 | |||
473 | // ################################################################################################# | ||
474 | |||
475 | /* | ||
453 | * [val] = linda_count( linda_ud, [slot [, ...]]) | 476 | * [val] = linda_count( linda_ud, [slot [, ...]]) |
454 | * | 477 | * |
455 | * Get a count of the pending elements in the specified keys | 478 | * Get a count of the pending elements in the specified keys |
@@ -1075,6 +1098,7 @@ namespace { | |||
1075 | { "__towatch", LG_linda_towatch }, // Decoda __towatch support | 1098 | { "__towatch", LG_linda_towatch }, // Decoda __towatch support |
1076 | #endif // HAVE_DECODA_SUPPORT() | 1099 | #endif // HAVE_DECODA_SUPPORT() |
1077 | { "cancel", LG_linda_cancel }, | 1100 | { "cancel", LG_linda_cancel }, |
1101 | { "collectgarbage", LG_linda_collectgarbage }, | ||
1078 | { "count", LG_linda_count }, | 1102 | { "count", LG_linda_count }, |
1079 | { "deep", LG_linda_deep }, | 1103 | { "deep", LG_linda_deep }, |
1080 | { "dump", LG_linda_dump }, | 1104 | { "dump", LG_linda_dump }, |