aboutsummaryrefslogtreecommitdiff
path: root/src/linda.h
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2024-10-25 16:45:28 +0200
committerBenoit Germain <benoit.germain@ubisoft.com>2024-10-25 16:45:28 +0200
commitc860f557a7ba72e6a39ea5db36e293de802adea5 (patch)
tree1d15a9b798b2f812c5315022d579e8f083b4385a /src/linda.h
parentf2d578555bf51da7a0acd1d1d7e724860b89a149 (diff)
downloadlanes-c860f557a7ba72e6a39ea5db36e293de802adea5.tar.gz
lanes-c860f557a7ba72e6a39ea5db36e293de802adea5.tar.bz2
lanes-c860f557a7ba72e6a39ea5db36e293de802adea5.zip
New linda:wake() and linda.status
Diffstat (limited to 'src/linda.h')
-rw-r--r--src/linda.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/linda.h b/src/linda.h
index c05fb14..02b0514 100644
--- a/src/linda.h
+++ b/src/linda.h
@@ -40,7 +40,15 @@ class Linda
40 } 40 }
41 }; 41 };
42 42
43 enum class Status
44 {
45 Active,
46 Cancelled
47 };
48 using enum Status;
49
43 private: 50 private:
51
44 static constexpr size_t kEmbeddedNameLength = 24; 52 static constexpr size_t kEmbeddedNameLength = 24;
45 using EmbeddedName = std::array<char, kEmbeddedNameLength>; 53 using EmbeddedName = std::array<char, kEmbeddedNameLength>;
46 // depending on the name length, it is either embedded inside the Linda, or allocated separately 54 // depending on the name length, it is either embedded inside the Linda, or allocated separately
@@ -53,7 +61,7 @@ class Linda
53 std::condition_variable writeHappened{}; 61 std::condition_variable writeHappened{};
54 Universe* const U{ nullptr }; // the universe this linda belongs to 62 Universe* const U{ nullptr }; // the universe this linda belongs to
55 KeeperIndex const keeperIndex{ -1 }; // the keeper associated to this linda 63 KeeperIndex const keeperIndex{ -1 }; // the keeper associated to this linda
56 CancelRequest cancelRequest{ CancelRequest::None }; 64 Status cancelStatus{ Status::Active };
57 65
58 public: 66 public:
59 [[nodiscard]] static void* operator new(size_t size_, Universe* U_) noexcept { return U_->internalAllocator.alloc(size_); } 67 [[nodiscard]] static void* operator new(size_t size_, Universe* U_) noexcept { return U_->internalAllocator.alloc(size_); }
@@ -89,6 +97,7 @@ class Linda
89 }; 97 };
90 void releaseKeeper(Keeper* keeper_) const; 98 void releaseKeeper(Keeper* keeper_) const;
91 [[nodiscard]] static int ProtectedCall(lua_State* L_, lua_CFunction f_); 99 [[nodiscard]] static int ProtectedCall(lua_State* L_, lua_CFunction f_);
100 void pushCancelString(lua_State* L_) const;
92 [[nodiscard]] KeeperOperationInProgress startKeeperOperation(lua_State* const L_) { return KeeperOperationInProgress{ *this, L_ }; }; 101 [[nodiscard]] KeeperOperationInProgress startKeeperOperation(lua_State* const L_) { return KeeperOperationInProgress{ *this, L_ }; };
93 [[nodiscard]] Keeper* whichKeeper() const { return U->keepers.getKeeper(keeperIndex); } 102 [[nodiscard]] Keeper* whichKeeper() const { return U->keepers.getKeeper(keeperIndex); }
94}; 103};