aboutsummaryrefslogtreecommitdiff
path: root/src/keeper.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/keeper.h')
-rw-r--r--src/keeper.h39
1 files changed, 21 insertions, 18 deletions
diff --git a/src/keeper.h b/src/keeper.h
index e081bea..627c7ea 100644
--- a/src/keeper.h
+++ b/src/keeper.h
@@ -11,20 +11,23 @@ extern "C" {
11#include "threading.h" 11#include "threading.h"
12#include "uniquekey.h" 12#include "uniquekey.h"
13 13
14#include <mutex>
15
14// forwards 16// forwards
15enum class LookupMode; 17enum class LookupMode;
16struct Universe; 18class Universe;
17 19
18struct Keeper 20struct Keeper
19{ 21{
20 MUTEX_T keeper_cs; 22 std::mutex m_mutex;
21 lua_State* L; 23 lua_State* L{ nullptr };
22 // int count; 24 // int count;
23}; 25};
24 26
25struct Keepers 27struct Keepers
26{ 28{
27 int nb_keepers; 29 int gc_threshold{ 0 };
30 int nb_keepers{ 0 };
28 Keeper keeper_array[1]; 31 Keeper keeper_array[1];
29}; 32};
30 33
@@ -35,23 +38,23 @@ static constexpr UniqueKey NIL_SENTINEL{ 0x7eaafa003a1d11a1ull };
35void init_keepers(Universe* U, lua_State* L); 38void init_keepers(Universe* U, lua_State* L);
36void close_keepers(Universe* U); 39void close_keepers(Universe* U);
37 40
38Keeper* which_keeper(Keepers* keepers_, uintptr_t magic_); 41[[nodiscard]] Keeper* which_keeper(Keepers* keepers_, uintptr_t magic_);
39Keeper* keeper_acquire(Keepers* keepers_, uintptr_t magic_); 42[[nodiscard]] Keeper* keeper_acquire(Keepers* keepers_, uintptr_t magic_);
40void keeper_release(Keeper* K); 43void keeper_release(Keeper* K_);
41void keeper_toggle_nil_sentinels(lua_State* L, int val_i_, LookupMode const mode_); 44void keeper_toggle_nil_sentinels(lua_State* L, int val_i_, LookupMode const mode_);
42int keeper_push_linda_storage(Universe* U, lua_State* L, void* ptr_, uintptr_t magic_); 45[[nodiscard]] int keeper_push_linda_storage(Universe* U, Dest L, void* ptr_, uintptr_t magic_);
43 46
44using keeper_api_t = lua_CFunction; 47using keeper_api_t = lua_CFunction;
45#define KEEPER_API(_op) keepercall_##_op 48#define KEEPER_API(_op) keepercall_##_op
46#define PUSH_KEEPER_FUNC lua_pushcfunction 49#define PUSH_KEEPER_FUNC lua_pushcfunction
47// lua_Cfunctions to run inside a keeper state 50// lua_Cfunctions to run inside a keeper state
48int keepercall_clear(lua_State* L); 51[[nodiscard]] int keepercall_clear(lua_State* L);
49int keepercall_send(lua_State* L); 52[[nodiscard]] int keepercall_send(lua_State* L);
50int keepercall_receive(lua_State* L); 53[[nodiscard]] int keepercall_receive(lua_State* L);
51int keepercall_receive_batched(lua_State* L); 54[[nodiscard]] int keepercall_receive_batched(lua_State* L);
52int keepercall_limit(lua_State* L); 55[[nodiscard]] int keepercall_limit(lua_State* L);
53int keepercall_get(lua_State* L); 56[[nodiscard]] int keepercall_get(lua_State* L);
54int keepercall_set(lua_State* L); 57[[nodiscard]] int keepercall_set(lua_State* L);
55int keepercall_count(lua_State* L); 58[[nodiscard]] int keepercall_count(lua_State* L);
56 59
57int keeper_call(Universe* U, lua_State* K, keeper_api_t _func, lua_State* L, void* linda, int starting_index); 60[[nodiscard]] int keeper_call(Universe* U, lua_State* K, keeper_api_t _func, lua_State* L, void* linda, int starting_index);