diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-03-25 17:55:31 +0100 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-03-25 17:55:31 +0100 |
commit | 051a587071e1bd25f72c77e84443be4a3426c83d (patch) | |
tree | 1a0bbf1a90f841a99985834b0509558495a66d15 /src/deep.h | |
parent | 0c060e6e4b9f99dc887b5dfebdae76fcde9524f1 (diff) | |
download | lanes-051a587071e1bd25f72c77e84443be4a3426c83d.tar.gz lanes-051a587071e1bd25f72c77e84443be4a3426c83d.tar.bz2 lanes-051a587071e1bd25f72c77e84443be4a3426c83d.zip |
C++ migration: Universe MUTEX_T replaced with std::mutex and std::atomic
Diffstat (limited to 'src/deep.h')
-rw-r--r-- | src/deep.h | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -16,6 +16,8 @@ extern "C" { | |||
16 | #include "lanesconf.h" | 16 | #include "lanesconf.h" |
17 | #include "uniquekey.h" | 17 | #include "uniquekey.h" |
18 | 18 | ||
19 | #include <atomic> | ||
20 | |||
19 | // forwards | 21 | // forwards |
20 | struct Universe; | 22 | struct Universe; |
21 | 23 | ||
@@ -38,8 +40,8 @@ using luaG_IdFunction = void*( lua_State* L, DeepOp op_); | |||
38 | 40 | ||
39 | // ################################################################################################ | 41 | // ################################################################################################ |
40 | 42 | ||
41 | // fnv164 of string "DEEP_VERSION_2" generated at https://www.pelock.com/products/hash-calculator | 43 | // xxh64 of string "DEEP_VERSION_3" generated at https://www.pelock.com/products/hash-calculator |
42 | static constexpr UniqueKey DEEP_VERSION{ 0xB4B0119C10642B29ull }; | 44 | static constexpr UniqueKey DEEP_VERSION{ 0xB2CC0FD9C0AE9674ull }; |
43 | 45 | ||
44 | // should be used as header for full userdata | 46 | // should be used as header for full userdata |
45 | struct DeepPrelude | 47 | struct DeepPrelude |
@@ -48,10 +50,10 @@ struct DeepPrelude | |||
48 | // when stored in a keeper state, the full userdata doesn't have a metatable, so we need direct access to the idfunc | 50 | // when stored in a keeper state, the full userdata doesn't have a metatable, so we need direct access to the idfunc |
49 | luaG_IdFunction* idfunc { nullptr }; | 51 | luaG_IdFunction* idfunc { nullptr }; |
50 | // data is destroyed when refcount is 0 | 52 | // data is destroyed when refcount is 0 |
51 | volatile int refcount{ 0 }; | 53 | std::atomic<int> m_refcount{ 0 }; |
52 | }; | 54 | }; |
53 | 55 | ||
54 | char const* push_deep_proxy( Universe* U, lua_State* L, DeepPrelude* prelude, int nuv_, LookupMode mode_); | 56 | char const* push_deep_proxy(lua_State* L, DeepPrelude* prelude, int nuv_, LookupMode mode_); |
55 | void free_deep_prelude( lua_State* L, DeepPrelude* prelude_); | 57 | void free_deep_prelude( lua_State* L, DeepPrelude* prelude_); |
56 | 58 | ||
57 | LANES_API int luaG_newdeepuserdata( lua_State* L, luaG_IdFunction* idfunc, int nuv_); | 59 | LANES_API int luaG_newdeepuserdata( lua_State* L, luaG_IdFunction* idfunc, int nuv_); |