aboutsummaryrefslogtreecommitdiff
path: root/src/keeper.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/keeper.hpp')
-rw-r--r--src/keeper.hpp44
1 files changed, 29 insertions, 15 deletions
diff --git a/src/keeper.hpp b/src/keeper.hpp
index 2354c2e..b77f1a9 100644
--- a/src/keeper.hpp
+++ b/src/keeper.hpp
@@ -18,7 +18,8 @@ struct Keeper
18 std::mutex mutex; 18 std::mutex mutex;
19 KeeperState K{ static_cast<lua_State*>(nullptr) }; 19 KeeperState K{ static_cast<lua_State*>(nullptr) };
20 20
21 [[nodiscard]] static void* operator new[](size_t size_, Universe* U_) noexcept; 21 [[nodiscard]]
22 static void* operator new[](size_t size_, Universe* U_) noexcept;
22 // can't actually delete the operator because the compiler generates stack unwinding code that could call it in case of exception 23 // can't actually delete the operator because the compiler generates stack unwinding code that could call it in case of exception
23 static void operator delete[](void* p_, Universe* U_); 24 static void operator delete[](void* p_, Universe* U_);
24 25
@@ -31,7 +32,8 @@ struct Keeper
31 Keeper& operator=(Keeper const&) = delete; 32 Keeper& operator=(Keeper const&) = delete;
32 Keeper& operator=(Keeper const&&) = delete; 33 Keeper& operator=(Keeper const&&) = delete;
33 34
34 [[nodiscard]] static int PushLindaStorage(Linda& linda_, DestState L_); 35 [[nodiscard]]
36 static int PushLindaStorage(Linda& linda_, DestState L_);
35}; 37};
36 38
37// ################################################################################################# 39// #################################################################################################
@@ -63,13 +65,17 @@ struct Keepers
63 65
64 Keepers() = default; 66 Keepers() = default;
65 void close(); 67 void close();
66 [[nodiscard]] Keeper* getKeeper(KeeperIndex idx_); 68 [[nodiscard]]
67 [[nodiscard]] int getNbKeepers() const; 69 Keeper* getKeeper(KeeperIndex idx_);
70 [[nodiscard]]
71 int getNbKeepers() const;
68 void initialize(Universe& U_, lua_State* L_, size_t nbKeepers_, int gc_threshold_); 72 void initialize(Universe& U_, lua_State* L_, size_t nbKeepers_, int gc_threshold_);
69}; 73};
70 74
71// ################################################################################################# 75// #################################################################################################
72 76
77DECLARE_UNIQUE_TYPE(KeeperCallResult, std::optional<int>);
78
73// xxh64 of string "kNilSentinel" generated at https://www.pelock.com/products/hash-calculator 79// xxh64 of string "kNilSentinel" generated at https://www.pelock.com/products/hash-calculator
74static constexpr UniqueKey kNilSentinel{ 0xC457D4EDDB05B5E4ull, "lanes.null" }; 80static constexpr UniqueKey kNilSentinel{ 0xC457D4EDDB05B5E4ull, "lanes.null" };
75 81
@@ -77,14 +83,22 @@ using keeper_api_t = lua_CFunction;
77#define KEEPER_API(_op) keepercall_##_op 83#define KEEPER_API(_op) keepercall_##_op
78 84
79// lua_Cfunctions to run inside a keeper state 85// lua_Cfunctions to run inside a keeper state
80[[nodiscard]] int keepercall_count(lua_State* L_); 86[[nodiscard]]
81[[nodiscard]] int keepercall_destruct(lua_State* L_); 87int keepercall_count(lua_State* L_);
82[[nodiscard]] int keepercall_get(lua_State* L_); 88[[nodiscard]]
83[[nodiscard]] int keepercall_limit(lua_State* L_); 89int keepercall_destruct(lua_State* L_);
84[[nodiscard]] int keepercall_receive(lua_State* L_); 90[[nodiscard]]
85[[nodiscard]] int keepercall_receive_batched(lua_State* L_); 91int keepercall_get(lua_State* L_);
86[[nodiscard]] int keepercall_send(lua_State* L_); 92[[nodiscard]]
87[[nodiscard]] int keepercall_set(lua_State* L_); 93int keepercall_limit(lua_State* L_);
88 94[[nodiscard]]
89DECLARE_UNIQUE_TYPE(KeeperCallResult, std::optional<int>); 95int keepercall_receive(lua_State* L_);
90[[nodiscard]] KeeperCallResult keeper_call(KeeperState K_, keeper_api_t func_, lua_State* L_, Linda* linda_, StackIndex starting_index_); 96[[nodiscard]]
97int keepercall_receive_batched(lua_State* L_);
98[[nodiscard]]
99int keepercall_send(lua_State* L_);
100[[nodiscard]]
101int keepercall_set(lua_State* L_);
102
103[[nodiscard]]
104KeeperCallResult keeper_call(KeeperState K_, keeper_api_t func_, lua_State* L_, Linda* linda_, StackIndex starting_index_);