aboutsummaryrefslogtreecommitdiff
path: root/src/linda.cpp
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2024-06-10 09:57:47 +0200
committerBenoit Germain <benoit.germain@ubisoft.com>2024-06-10 09:57:47 +0200
commitd93e1fcea482f8348bb42171befea08466f8541f (patch)
tree885952cd1de3f4b7d923f61ba3cdf2b358749483 /src/linda.cpp
parent9a7c7f5f7ec66576447b4d225066cc388f8ca6b0 (diff)
downloadlanes-d93e1fcea482f8348bb42171befea08466f8541f.tar.gz
lanes-d93e1fcea482f8348bb42171befea08466f8541f.tar.bz2
lanes-d93e1fcea482f8348bb42171befea08466f8541f.zip
Suspend/resume GC around Linda operations
Diffstat (limited to 'src/linda.cpp')
-rw-r--r--src/linda.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/linda.cpp b/src/linda.cpp
index e4ae3f4..81926f9 100644
--- a/src/linda.cpp
+++ b/src/linda.cpp
@@ -180,6 +180,11 @@ int Linda::ProtectedCall(lua_State* L_, lua_CFunction f_)
180 if (_K == nullptr) 180 if (_K == nullptr)
181 return 0; 181 return 0;
182 182
183 // no GC allowed during the call, because we don't want to trigger collection of another linda
184 // bound to the same keeper, as that would cause a deadlock when trying to acquire it while
185 // doing LindaFactory::deleteDeepObjectInternal -> keeper_call(clear)
186 lua_gc(L_, LUA_GCSTOP, 0);
187
183 LUA_ASSERT_CODE(auto const _koip{ _linda->startKeeperOperation(L_) }); 188 LUA_ASSERT_CODE(auto const _koip{ _linda->startKeeperOperation(L_) });
184 // if we didn't do anything wrong, the keeper stack should be clean 189 // if we didn't do anything wrong, the keeper stack should be clean
185 LUA_ASSERT(L_, lua_gettop(_K) == 0); 190 LUA_ASSERT(L_, lua_gettop(_K) == 0);
@@ -192,6 +197,9 @@ int Linda::ProtectedCall(lua_State* L_, lua_CFunction f_)
192 // whatever happens, the keeper state stack must be empty when we are done 197 // whatever happens, the keeper state stack must be empty when we are done
193 lua_settop(_K, 0); 198 lua_settop(_K, 0);
194 199
200 // restore normal GC operations
201 lua_gc(L_, LUA_GCRESTART, 0);
202
195 // release the keeper 203 // release the keeper
196 _linda->releaseKeeper(_keeper); 204 _linda->releaseKeeper(_keeper);
197 205