aboutsummaryrefslogtreecommitdiff
path: root/src/universe.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/universe.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/universe.h b/src/universe.h
new file mode 100644
index 0000000..0ca5bf7
--- /dev/null
+++ b/src/universe.h
@@ -0,0 +1,66 @@
1/*
2* UNIVERSE.H
3*/
4#ifndef UNIVERSE_H
5#define UNIVERSE_H
6
7#include "lua.h"
8#include "threading.h"
9// MUTEX_T
10
11// ################################################################################################
12
13/*
14* Do we want to activate full lane tracking feature? (EXPERIMENTAL)
15*/
16#define HAVE_LANE_TRACKING 1
17
18// ################################################################################################
19
20// everything regarding the a Lanes universe is stored in that global structure
21// held as a full userdata in the master Lua state that required it for the first time
22// don't forget to initialize all members in LG_configure()
23struct s_Universe
24{
25 // for verbose errors
26 bool_t verboseErrors;
27
28 lua_CFunction on_state_create_func;
29
30 struct s_Keepers* keepers;
31
32 // Initialized by 'init_once_LOCKED()': the deep userdata Linda object
33 // used for timers (each lane will get a proxy to this)
34 volatile struct DEEP_PRELUDE* timer_deep; // = NULL
35
36#if HAVE_LANE_TRACKING
37 MUTEX_T tracking_cs;
38 struct s_lane* volatile tracking_first; // will change to TRACKING_END if we want to activate tracking
39#endif // HAVE_LANE_TRACKING
40
41 MUTEX_T selfdestruct_cs;
42
43 // require() serialization
44 MUTEX_T require_cs;
45
46 // Lock for reference counter inc/dec locks (to be initialized by outside code) TODO: get rid of this and use atomics instead!
47 MUTEX_T deep_lock;
48 MUTEX_T mtid_lock;
49
50 int last_mt_id;
51
52#if USE_DEBUG_SPEW
53 int debugspew_indent_depth;
54#endif // USE_DEBUG_SPEW
55
56 struct s_lane* volatile selfdestruct_first;
57 // After a lane has removed itself from the chain, it still performs some processing.
58 // The terminal desinit sequence should wait for all such processing to terminate before force-killing threads
59 int volatile selfdestructing_count;
60};
61
62struct s_Universe* universe_get( lua_State* L);
63struct s_Universe* universe_create( lua_State* L);
64void universe_store( lua_State* L, struct s_Universe* U);
65
66#endif // UNIVERSE_H