aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2024-11-27 18:14:32 +0100
committerBenoit Germain <benoit.germain@ubisoft.com>2024-11-27 18:14:32 +0100
commit4f8e92b37b7c20545ca08fefd1f1c0ca7d1673a9 (patch)
tree3dda322bc32cc49f53c8399a5bb03b04bf616cdc
parent95d8604d0822b32f2561c5b29f18acf909ead935 (diff)
downloadlanes-4f8e92b37b7c20545ca08fefd1f1c0ca7d1673a9.tar.gz
lanes-4f8e92b37b7c20545ca08fefd1f1c0ca7d1673a9.tar.bz2
lanes-4f8e92b37b7c20545ca08fefd1f1c0ca7d1673a9.zip
Make lanes.register() available as an exported C function lanes_register()
-rw-r--r--CHANGES6
-rw-r--r--docs/index.html3
-rw-r--r--src/lanes.cpp4
-rw-r--r--src/lanes.hpp2
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 @@
1CHANGES: 1CHANGES:
2 2
3CHANGE 3: BGe 24-Sep-24 3CHANGE 2: BGe 27-Nov-24
4 * Modernized lanes.gen() library list processing code.
5
6CHANGE 2: BGe 04-Jul-24
7 * Internal changes 4 * Internal changes
8 - Lanes is implemented in C++20: thread, condition_variable, mutex, string_view, variant, lambdas, templates, and more! 5 - Lanes is implemented in C++20: thread, condition_variable, mutex, string_view, variant, lambdas, templates, and more!
9 - Almost all platform-specific code is gone (only a small bit for thread priority and affinity remains). 6 - 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
12 * Lanes API changes 9 * Lanes API changes
13 - Version is now 4.0.0 10 - Version is now 4.0.0
14 - Lanes module: 11 - Lanes module:
12 - lanes.register() is also available as lanes_register() in the exported C API.
15 - lanes.sleep() accepts a new argument "indefinitely" to block forever (until hard cancellation is received). 13 - lanes.sleep() accepts a new argument "indefinitely" to block forever (until hard cancellation is received).
16 - function set_debug_threadname() available inside a Lane is renamed lane_threadname(); can now both read and write the name. 14 - function set_debug_threadname() available inside a Lane is renamed lane_threadname(); can now both read and write the name.
17 - new function lanes.finally(). Installs a function that gets called at Lanes shutdown after attempting to terminate all lanes. 15 - 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 @@
440 <br /> 440 <br />
441 Use <tt>lanes.require()</tt> for this purpose. This will call the original <tt>require()</tt>, then add the result to the lookup databases. 441 Use <tt>lanes.require()</tt> for this purpose. This will call the original <tt>require()</tt>, then add the result to the lookup databases.
442 <br /> 442 <br />
443 It is also possible to register a given module <i>a posteriori</i> with <tt>lanes.register()</tt>. This function will raise an error if the registered module is not a function or table. 443 It is also possible to register a given module <i>a posteriori</i> with <tt>lanes.register()</tt>. This function will raise an error if the registered module is not a function or table.<br />
444 Embedders can call the equivalent function <tt>lanes_register()</tt> from the C side.
444</p> 445</p>
445 446
446<table border="1" bgcolor="#FFFFE0" cellpadding="10" style="width:50%"> 447<table border="1" bgcolor="#FFFFE0" cellpadding="10" style="width:50%">
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)
213// --- If a client wants to transfer stuff of a previously required module from the current state to another Lane, the module must be registered 213// --- If a client wants to transfer stuff of a previously required module from the current state to another Lane, the module must be registered
214// to populate the lookup database in the source lane (and in the destination too, of course) 214// to populate the lookup database in the source lane (and in the destination too, of course)
215// lanes.register( "modname", module) 215// lanes.register( "modname", module)
216LUAG_FUNC(register) 216int lanes_register(lua_State* const L_)
217{ 217{
218 std::string_view const _name{ luaG_checkstring(L_, StackIndex{ 1 }) }; 218 std::string_view const _name{ luaG_checkstring(L_, StackIndex{ 1 }) };
219 LuaType const _mod_type{ luaG_type(L_, StackIndex{ 2 }) }; 219 LuaType const _mod_type{ luaG_type(L_, StackIndex{ 2 }) };
@@ -649,7 +649,7 @@ namespace {
649 { "linda", LG_linda }, 649 { "linda", LG_linda },
650 { "nameof", LG_nameof }, 650 { "nameof", LG_nameof },
651 { "now_secs", LG_now_secs }, 651 { "now_secs", LG_now_secs },
652 { "register", LG_register }, 652 { "register", lanes_register },
653 { "set_singlethreaded", LG_set_singlethreaded }, 653 { "set_singlethreaded", LG_set_singlethreaded },
654 { "set_thread_priority", LG_set_thread_priority }, 654 { "set_thread_priority", LG_set_thread_priority },
655 { "set_thread_affinity", LG_set_thread_affinity }, 655 { "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_);
18LANES_API void luaopen_lanes_embedded(lua_State* L_, lua_CFunction luaopen_lanes_); 18LANES_API void luaopen_lanes_embedded(lua_State* L_, lua_CFunction luaopen_lanes_);
19using luaopen_lanes_embedded_t = void (*)(lua_State* L_, lua_CFunction luaopen_lanes_); 19using luaopen_lanes_embedded_t = void (*)(lua_State* L_, lua_CFunction luaopen_lanes_);
20static_assert(std::is_same_v<decltype(&luaopen_lanes_embedded), luaopen_lanes_embedded_t>, "signature changed: check all uses of luaopen_lanes_embedded_t"); 20static_assert(std::is_same_v<decltype(&luaopen_lanes_embedded), luaopen_lanes_embedded_t>, "signature changed: check all uses of luaopen_lanes_embedded_t");
21
22LANES_API int lanes_register(lua_State* L_);