aboutsummaryrefslogtreecommitdiff
path: root/src/lanes_private.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lanes_private.h')
-rw-r--r--src/lanes_private.h14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/lanes_private.h b/src/lanes_private.h
index 85b3c52..1530b9e 100644
--- a/src/lanes_private.h
+++ b/src/lanes_private.h
@@ -72,21 +72,13 @@ struct Lane
72 // For tracking only 72 // For tracking only
73}; 73};
74 74
75// xxh64 of string "LANE_POINTER_REGKEY" generated at https://www.pelock.com/products/hash-calculator
76static constexpr UniqueKey LANE_POINTER_REGKEY{ 0xB3022205633743BCull }; // used as registry key
77
75// To allow free-running threads (longer lifespan than the handle's) 78// To allow free-running threads (longer lifespan than the handle's)
76// 'Lane' are malloc/free'd and the handle only carries a pointer. 79// 'Lane' are malloc/free'd and the handle only carries a pointer.
77// This is not deep userdata since the handle's not portable among lanes. 80// This is not deep userdata since the handle's not portable among lanes.
78// 81//
79#define lua_toLane( L, i) (*((Lane**) luaL_checkudata( L, i, "Lane"))) 82#define lua_toLane( L, i) (*((Lane**) luaL_checkudata( L, i, "Lane")))
80 83
81static inline Lane* get_lane_from_registry( lua_State* L)
82{
83 STACK_GROW( L, 1);
84 STACK_CHECK_START_REL(L, 0);
85 CANCEL_TEST_KEY.query_registry(L);
86 Lane* const s{ lua_tolightuserdata<Lane>(L, -1) }; // lightuserdata (true 'Lane' pointer) / nil
87 lua_pop( L, 1);
88 STACK_CHECK( L, 0);
89 return s;
90}
91
92int push_thread_status( lua_State* L, Lane* s); 84int push_thread_status( lua_State* L, Lane* s);