diff options
Diffstat (limited to 'src/linda.hpp')
-rw-r--r-- | src/linda.hpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/linda.hpp b/src/linda.hpp index 2d5c9dc..7874db3 100644 --- a/src/linda.hpp +++ b/src/linda.hpp | |||
@@ -42,19 +42,21 @@ class Linda final | |||
42 | }; | 42 | }; |
43 | using enum Status; | 43 | using enum Status; |
44 | 44 | ||
45 | private: | 45 | public: |
46 | Universe* const U{ nullptr }; // the universe this linda belongs to | ||
46 | 47 | ||
48 | private: | ||
47 | static constexpr size_t kEmbeddedNameLength = 24; | 49 | static constexpr size_t kEmbeddedNameLength = 24; |
48 | using EmbeddedName = std::array<char, kEmbeddedNameLength>; | 50 | using EmbeddedName = std::array<char, kEmbeddedNameLength>; |
49 | // depending on the name length, it is either embedded inside the Linda, or allocated separately | 51 | // depending on the name length, it is either embedded inside the Linda, or allocated separately |
50 | std::variant<std::string_view, EmbeddedName> nameVariant{}; | 52 | std::variant<std::string_view, EmbeddedName> nameVariant{}; |
51 | // counts the keeper operations in progress | 53 | // counts the keeper operations in progress |
52 | std::atomic<int> keeperOperationCount{}; | 54 | std::atomic<int> keeperOperationCount{}; |
55 | lua_Duration wakePeriod{}; | ||
53 | 56 | ||
54 | public: | 57 | public: |
55 | std::condition_variable readHappened{}; | 58 | std::condition_variable readHappened{}; |
56 | std::condition_variable writeHappened{}; | 59 | std::condition_variable writeHappened{}; |
57 | Universe* const U{ nullptr }; // the universe this linda belongs to | ||
58 | KeeperIndex const keeperIndex{ -1 }; // the keeper associated to this linda | 60 | KeeperIndex const keeperIndex{ -1 }; // the keeper associated to this linda |
59 | Status cancelStatus{ Status::Active }; | 61 | Status cancelStatus{ Status::Active }; |
60 | 62 | ||
@@ -68,7 +70,7 @@ class Linda final | |||
68 | static void operator delete(void* p_) { static_cast<Linda*>(p_)->U->internalAllocator.free(p_, sizeof(Linda)); } | 70 | static void operator delete(void* p_) { static_cast<Linda*>(p_)->U->internalAllocator.free(p_, sizeof(Linda)); } |
69 | 71 | ||
70 | ~Linda(); | 72 | ~Linda(); |
71 | Linda(Universe* U_, LindaGroup group_, std::string_view const& name_); | 73 | Linda(Universe* U_, std::string_view const& name_, lua_Duration wake_period_, LindaGroup group_); |
72 | Linda() = delete; | 74 | Linda() = delete; |
73 | // non-copyable, non-movable | 75 | // non-copyable, non-movable |
74 | Linda(Linda const&) = delete; | 76 | Linda(Linda const&) = delete; |
@@ -92,6 +94,8 @@ class Linda final | |||
92 | [[nodiscard]] | 94 | [[nodiscard]] |
93 | std::string_view getName() const; | 95 | std::string_view getName() const; |
94 | [[nodiscard]] | 96 | [[nodiscard]] |
97 | auto getWakePeriod() const { return wakePeriod; } | ||
98 | [[nodiscard]] | ||
95 | bool inKeeperOperation() const { return keeperOperationCount.load(std::memory_order_seq_cst) != 0; } | 99 | bool inKeeperOperation() const { return keeperOperationCount.load(std::memory_order_seq_cst) != 0; } |
96 | template <typename T = uintptr_t> | 100 | template <typename T = uintptr_t> |
97 | [[nodiscard]] | 101 | [[nodiscard]] |