diff options
author | Benoit Germain <b n t DOT g e r m a i n AT g m a i l DOT c o m> | 2018-11-25 12:45:11 +0100 |
---|---|---|
committer | Benoit Germain <b n t DOT g e r m a i n AT g m a i l DOT c o m> | 2018-11-25 12:45:11 +0100 |
commit | 8d6500fe389624be422ee546f71a1efd4456eabe (patch) | |
tree | b9462a142180b8edb01e1eb284a42fea9f0156bc /src/universe.h | |
parent | 60e5d94af372471c2a3bab91963588ca650bff7b (diff) | |
download | lanes-8d6500fe389624be422ee546f71a1efd4456eabe.tar.gz lanes-8d6500fe389624be422ee546f71a1efd4456eabe.tar.bz2 lanes-8d6500fe389624be422ee546f71a1efd4456eabe.zip |
protect_allocator configure option is gone, long live allocator (more embedders-friendly)
Diffstat (limited to 'src/universe.h')
-rw-r--r-- | src/universe.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/universe.h b/src/universe.h index 359dc90..8727bf7 100644 --- a/src/universe.h +++ b/src/universe.h | |||
@@ -24,6 +24,24 @@ typedef struct s_Lane Lane; | |||
24 | 24 | ||
25 | // ################################################################################################ | 25 | // ################################################################################################ |
26 | 26 | ||
27 | // everything we need to provide to lua_newstate() | ||
28 | struct AllocatorDefinition_s | ||
29 | { | ||
30 | lua_Alloc allocF; | ||
31 | void* allocUD; | ||
32 | }; | ||
33 | typedef struct AllocatorDefinition_s AllocatorDefinition; | ||
34 | |||
35 | // mutex-protected allocator for use with Lua states that share a non-threadsafe allocator | ||
36 | struct ProtectedAllocator_s | ||
37 | { | ||
38 | AllocatorDefinition definition; | ||
39 | MUTEX_T lock; | ||
40 | }; | ||
41 | typedef struct ProtectedAllocator_s ProtectedAllocator; | ||
42 | |||
43 | // ################################################################################################ | ||
44 | |||
27 | // everything regarding the a Lanes universe is stored in that global structure | 45 | // everything regarding the a Lanes universe is stored in that global structure |
28 | // held as a full userdata in the master Lua state that required it for the first time | 46 | // held as a full userdata in the master Lua state that required it for the first time |
29 | // don't forget to initialize all members in LG_configure() | 47 | // don't forget to initialize all members in LG_configure() |
@@ -34,8 +52,16 @@ struct s_Universe | |||
34 | 52 | ||
35 | bool_t demoteFullUserdata; | 53 | bool_t demoteFullUserdata; |
36 | 54 | ||
55 | // before a state is created, this function will be called to obtain the allocator | ||
56 | lua_CFunction provide_allocator; | ||
57 | |||
58 | // after a state is created, this function will be called right after the bases libraries are loaded | ||
37 | lua_CFunction on_state_create_func; | 59 | lua_CFunction on_state_create_func; |
38 | 60 | ||
61 | // Initialized and used only if allocator="protected" is found in the configuration settings | ||
62 | // contains a mutex and the original allocator definition | ||
63 | ProtectedAllocator protected_allocator; | ||
64 | |||
39 | Keepers* keepers; | 65 | Keepers* keepers; |
40 | 66 | ||
41 | // Initialized by 'init_once_LOCKED()': the deep userdata Linda object | 67 | // Initialized by 'init_once_LOCKED()': the deep userdata Linda object |