diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-05-31 11:40:28 +0200 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-05-31 11:40:28 +0200 |
commit | a65a84cfad4eae38e5e84b1ab11f60a62833f287 (patch) | |
tree | 3d3b6cc88c188f2c34d3283e081316d6cc05ae83 /src/deep.cpp | |
parent | 731556711e453a501f1d1d06a6013b8fbd53414e (diff) | |
download | lanes-a65a84cfad4eae38e5e84b1ab11f60a62833f287.tar.gz lanes-a65a84cfad4eae38e5e84b1ab11f60a62833f287.tar.bz2 lanes-a65a84cfad4eae38e5e84b1ab11f60a62833f287.zip |
Improved multi-keeper tests
Diffstat (limited to 'src/deep.cpp')
-rw-r--r-- | src/deep.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/deep.cpp b/src/deep.cpp index f5716bf..34cc4b4 100644 --- a/src/deep.cpp +++ b/src/deep.cpp | |||
@@ -78,9 +78,9 @@ namespace { | |||
78 | 78 | ||
79 | // can work without a universe if creating a deep userdata from some external C module when Lanes isn't loaded | 79 | // can work without a universe if creating a deep userdata from some external C module when Lanes isn't loaded |
80 | // in that case, we are not multithreaded and locking isn't necessary anyway | 80 | // in that case, we are not multithreaded and locking isn't necessary anyway |
81 | bool const isLastRef{ _p->refcount.fetch_sub(1, std::memory_order_relaxed) == 1 }; | 81 | bool const _isLastRef{ _p->refcount.fetch_sub(1, std::memory_order_relaxed) == 1 }; |
82 | 82 | ||
83 | if (isLastRef) { | 83 | if (_isLastRef) { |
84 | // retrieve wrapped __gc, if any | 84 | // retrieve wrapped __gc, if any |
85 | lua_pushvalue(L_, lua_upvalueindex(1)); // L_: self __gc? | 85 | lua_pushvalue(L_, lua_upvalueindex(1)); // L_: self __gc? |
86 | if (!lua_isnil(L_, -1)) { | 86 | if (!lua_isnil(L_, -1)) { |
@@ -123,6 +123,7 @@ namespace { | |||
123 | // ################################################################################################# | 123 | // ################################################################################################# |
124 | // ################################################################################################# | 124 | // ################################################################################################# |
125 | 125 | ||
126 | // NEVER call deleteDeepObjectInternal by itself, ALWAYS go through DeleteDeepObject() | ||
126 | void DeepFactory::DeleteDeepObject(lua_State* const L_, DeepPrelude* const o_) | 127 | void DeepFactory::DeleteDeepObject(lua_State* const L_, DeepPrelude* const o_) |
127 | { | 128 | { |
128 | STACK_CHECK_START_REL(L_, 0); | 129 | STACK_CHECK_START_REL(L_, 0); |
@@ -310,7 +311,7 @@ int DeepFactory::pushDeepUserdata(DestState const L_, int const nuv_) const | |||
310 | 311 | ||
311 | if (_prelude->magic != kDeepVersion) { | 312 | if (_prelude->magic != kDeepVersion) { |
312 | // just in case, don't leak the newly allocated deep userdata object | 313 | // just in case, don't leak the newly allocated deep userdata object |
313 | deleteDeepObjectInternal(L_, _prelude); | 314 | DeleteDeepObject(L_, _prelude); |
314 | raise_luaL_error(L_, "Bad Deep Factory: kDeepVersion is incorrect, rebuild your implementation with the latest deep implementation"); | 315 | raise_luaL_error(L_, "Bad Deep Factory: kDeepVersion is incorrect, rebuild your implementation with the latest deep implementation"); |
315 | } | 316 | } |
316 | 317 | ||
@@ -319,7 +320,7 @@ int DeepFactory::pushDeepUserdata(DestState const L_, int const nuv_) const | |||
319 | 320 | ||
320 | if (lua_gettop(L_) - _oldtop != 0) { | 321 | if (lua_gettop(L_) - _oldtop != 0) { |
321 | // just in case, don't leak the newly allocated deep userdata object | 322 | // just in case, don't leak the newly allocated deep userdata object |
322 | deleteDeepObjectInternal(L_, _prelude); | 323 | DeleteDeepObject(L_, _prelude); |
323 | raise_luaL_error(L_, "Bad DeepFactory::newDeepObjectInternal overload: should not push anything on the stack"); | 324 | raise_luaL_error(L_, "Bad DeepFactory::newDeepObjectInternal overload: should not push anything on the stack"); |
324 | } | 325 | } |
325 | 326 | ||