From 4f8e92b37b7c20545ca08fefd1f1c0ca7d1673a9 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Wed, 27 Nov 2024 18:14:32 +0100 Subject: Make lanes.register() available as an exported C function lanes_register() --- CHANGES | 6 ++---- docs/index.html | 3 ++- src/lanes.cpp | 4 ++-- src/lanes.hpp | 2 ++ 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGES b/CHANGES index b8dff6d..a2dbad4 100644 --- a/CHANGES +++ b/CHANGES @@ -1,9 +1,6 @@ CHANGES: -CHANGE 3: BGe 24-Sep-24 - * Modernized lanes.gen() library list processing code. - -CHANGE 2: BGe 04-Jul-24 +CHANGE 2: BGe 27-Nov-24 * Internal changes - Lanes is implemented in C++20: thread, condition_variable, mutex, string_view, variant, lambdas, templates, and more! - Almost all platform-specific code is gone (only a small bit for thread priority and affinity remains). @@ -12,6 +9,7 @@ CHANGE 2: BGe 04-Jul-24 * Lanes API changes - Version is now 4.0.0 - Lanes module: + - lanes.register() is also available as lanes_register() in the exported C API. - lanes.sleep() accepts a new argument "indefinitely" to block forever (until hard cancellation is received). - function set_debug_threadname() available inside a Lane is renamed lane_threadname(); can now both read and write the name. - new function lanes.finally(). Installs a function that gets called at Lanes shutdown after attempting to terminate all lanes. diff --git a/docs/index.html b/docs/index.html index edac9d8..cccfd6f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -440,7 +440,8 @@
Use lanes.require() for this purpose. This will call the original require(), then add the result to the lookup databases.
- It is also possible to register a given module a posteriori with lanes.register(). This function will raise an error if the registered module is not a function or table. + It is also possible to register a given module a posteriori with lanes.register(). This function will raise an error if the registered module is not a function or table.
+ Embedders can call the equivalent function lanes_register() from the C side.

diff --git a/src/lanes.cpp b/src/lanes.cpp index 39caee9..d58f113 100644 --- a/src/lanes.cpp +++ b/src/lanes.cpp @@ -213,7 +213,7 @@ LUAG_FUNC(require) // --- If a client wants to transfer stuff of a previously required module from the current state to another Lane, the module must be registered // to populate the lookup database in the source lane (and in the destination too, of course) // lanes.register( "modname", module) -LUAG_FUNC(register) +int lanes_register(lua_State* const L_) { std::string_view const _name{ luaG_checkstring(L_, StackIndex{ 1 }) }; LuaType const _mod_type{ luaG_type(L_, StackIndex{ 2 }) }; @@ -649,7 +649,7 @@ namespace { { "linda", LG_linda }, { "nameof", LG_nameof }, { "now_secs", LG_now_secs }, - { "register", LG_register }, + { "register", lanes_register }, { "set_singlethreaded", LG_set_singlethreaded }, { "set_thread_priority", LG_set_thread_priority }, { "set_thread_affinity", LG_set_thread_affinity }, diff --git a/src/lanes.hpp b/src/lanes.hpp index a3731e4..550e6e6 100644 --- a/src/lanes.hpp +++ b/src/lanes.hpp @@ -18,3 +18,5 @@ LANES_API int luaopen_lanes_core(lua_State* L_); LANES_API void luaopen_lanes_embedded(lua_State* L_, lua_CFunction luaopen_lanes_); using luaopen_lanes_embedded_t = void (*)(lua_State* L_, lua_CFunction luaopen_lanes_); static_assert(std::is_same_v, "signature changed: check all uses of luaopen_lanes_embedded_t"); + +LANES_API int lanes_register(lua_State* L_); -- cgit v1.2.3-55-g6feb