diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-12-10 18:28:34 +0100 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-12-10 18:28:34 +0100 |
commit | 30e073f58659a8b24890c834cb8b342adc8c5feb (patch) | |
tree | 16650b0f1de890f063ea36bf483504600b82d0a4 /src/deep.hpp | |
parent | e4543302fcacf871b319710e925919203f520f32 (diff) | |
download | lanes-30e073f58659a8b24890c834cb8b342adc8c5feb.tar.gz lanes-30e073f58659a8b24890c834cb8b342adc8c5feb.tar.bz2 lanes-30e073f58659a8b24890c834cb8b342adc8c5feb.zip |
DeepFactory counts the number of active Deep objects
Diffstat (limited to 'src/deep.hpp')
-rw-r--r-- | src/deep.hpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/deep.hpp b/src/deep.hpp index 6bc3b20..8196e66 100644 --- a/src/deep.hpp +++ b/src/deep.hpp | |||
@@ -50,6 +50,10 @@ class DeepPrelude | |||
50 | // external C modules should create a single object implementing that interface for each Deep userdata class they want to expose | 50 | // external C modules should create a single object implementing that interface for each Deep userdata class they want to expose |
51 | class DeepFactory | 51 | class DeepFactory |
52 | { | 52 | { |
53 | private: | ||
54 | // the current count of deep object instances | ||
55 | mutable std::atomic<int> deepObjectCount{}; | ||
56 | |||
53 | protected: | 57 | protected: |
54 | // protected non-virtual destructor: Lanes won't manage the Factory's lifetime | 58 | // protected non-virtual destructor: Lanes won't manage the Factory's lifetime |
55 | DeepFactory() = default; | 59 | DeepFactory() = default; |
@@ -80,6 +84,8 @@ class DeepFactory | |||
80 | // NVI: public interface | 84 | // NVI: public interface |
81 | static void DeleteDeepObject(lua_State* L_, DeepPrelude* o_); | 85 | static void DeleteDeepObject(lua_State* L_, DeepPrelude* o_); |
82 | [[nodiscard]] | 86 | [[nodiscard]] |
87 | int getObjectCount() const { return deepObjectCount.load(std::memory_order_relaxed); } | ||
88 | [[nodiscard]] | ||
83 | static bool IsDeepUserdata(lua_State* const L_, StackIndex const idx_); | 89 | static bool IsDeepUserdata(lua_State* const L_, StackIndex const idx_); |
84 | [[nodiscard]] | 90 | [[nodiscard]] |
85 | static DeepFactory* LookupFactory(lua_State* L_, StackIndex index_, LookupMode mode_); | 91 | static DeepFactory* LookupFactory(lua_State* L_, StackIndex index_, LookupMode mode_); |