aboutsummaryrefslogtreecommitdiff
path: root/src/linda.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/linda.hpp')
-rw-r--r--src/linda.hpp24
1 files changed, 1 insertions, 23 deletions
diff --git a/src/linda.hpp b/src/linda.hpp
index cff30e5..f02c46e 100644
--- a/src/linda.hpp
+++ b/src/linda.hpp
@@ -14,26 +14,6 @@ class Linda final
14: public DeepPrelude // Deep userdata MUST start with this header 14: public DeepPrelude // Deep userdata MUST start with this header
15{ 15{
16 public: 16 public:
17 class [[nodiscard]] KeeperOperationInProgress final
18 {
19 private:
20 Linda& linda;
21 lua_State* const L{}; // just here for inspection while debugging
22
23 public:
24 KeeperOperationInProgress(Linda& linda_, lua_State* const L_)
25 : linda{ linda_ }
26 , L{ L_ }
27 {
28 [[maybe_unused]] UnusedInt const _prev{ linda.keeperOperationCount.fetch_add(1, std::memory_order_seq_cst) };
29 }
30
31 public:
32 ~KeeperOperationInProgress()
33 {
34 [[maybe_unused]] UnusedInt const _prev{ linda.keeperOperationCount.fetch_sub(1, std::memory_order_seq_cst) };
35 }
36 };
37 17
38 enum class [[nodiscard]] Status 18 enum class [[nodiscard]] Status
39 { 19 {
@@ -51,7 +31,7 @@ class Linda final
51 // depending on the name length, it is either embedded inside the Linda, or allocated separately 31 // depending on the name length, it is either embedded inside the Linda, or allocated separately
52 std::variant<std::string_view, EmbeddedName> nameVariant{}; 32 std::variant<std::string_view, EmbeddedName> nameVariant{};
53 // counts the keeper operations in progress 33 // counts the keeper operations in progress
54 std::atomic<int> keeperOperationCount{}; 34 mutable std::atomic<int> keeperOperationCount{};
55 lua_Duration wakePeriod{}; 35 lua_Duration wakePeriod{};
56 36
57 public: 37 public:
@@ -110,7 +90,5 @@ class Linda final
110 static int ProtectedCall(lua_State* L_, lua_CFunction f_); 90 static int ProtectedCall(lua_State* L_, lua_CFunction f_);
111 void pushCancelString(lua_State* L_) const; 91 void pushCancelString(lua_State* L_) const;
112 [[nodiscard]] 92 [[nodiscard]]
113 KeeperOperationInProgress startKeeperOperation(lua_State* const L_) { return KeeperOperationInProgress{ *this, L_ }; };
114 [[nodiscard]]
115 Keeper* whichKeeper() const { return U->keepers.getKeeper(keeperIndex); } 93 Keeper* whichKeeper() const { return U->keepers.getKeeper(keeperIndex); }
116}; 94};