diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-07-03 13:21:45 +0200 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-07-03 13:21:45 +0200 |
commit | ffedd175233975f3ca9ac940df9883898d5ace25 (patch) | |
tree | a073d90a98b188635b19027d797e2c8b663501e0 | |
parent | f81fe873dd24f93306f0f667fc47766990a9321b (diff) | |
download | lanes-ffedd175233975f3ca9ac940df9883898d5ace25.tar.gz lanes-ffedd175233975f3ca9ac940df9883898d5ace25.tar.bz2 lanes-ffedd175233975f3ca9ac940df9883898d5ace25.zip |
Renamed set_debug_threadname → lane_threadname (can also read the current name now)
Diffstat (limited to '')
-rw-r--r-- | CHANGES | 3 | ||||
-rw-r--r-- | docs/index.html | 4 | ||||
-rw-r--r-- | src/lane.cpp | 48 | ||||
-rw-r--r-- | src/lane.h | 14 | ||||
-rw-r--r-- | src/tracker.cpp | 2 | ||||
-rw-r--r-- | tests/basic.lua | 12 | ||||
-rw-r--r-- | tests/cancel.lua | 2 | ||||
-rw-r--r-- | tests/deadlock.lua | 2 | ||||
-rw-r--r-- | tests/fibonacci.lua | 4 | ||||
-rw-r--r-- | tests/track_lanes.lua | 8 |
10 files changed, 64 insertions, 35 deletions
@@ -24,6 +24,7 @@ CHANGE 2: BGe 11-Jun-24 | |||
24 | - lane function body must return a non-nil first value on success if lane is waited upon with lane:join(). | 24 | - lane function body must return a non-nil first value on success if lane is waited upon with lane:join(). |
25 | - lanes.sleep() accept a new argument "indefinitely" to block forever (until hard cancellation is received). | 25 | - lanes.sleep() accept a new argument "indefinitely" to block forever (until hard cancellation is received). |
26 | - lanes.gen() is stricter wrt base libraries (can raise an error if it doesn't exist in the Lua flavor it's built against). | 26 | - lanes.gen() is stricter wrt base libraries (can raise an error if it doesn't exist in the Lua flavor it's built against). |
27 | - function set_debug_threadname() available inside a Lane is renamed lane_threadname(); can now both read and write the name. | ||
27 | - Lindas: | 28 | - Lindas: |
28 | - providing "auto" as name when constructing a Linda cause Lanes to provide a name built from the source location of the construction. | 29 | - providing "auto" as name when constructing a Linda cause Lanes to provide a name built from the source location of the construction. |
29 | - specifying a group to lanes.linda() is mandatory when Lanes is configured with user Keepers. | 30 | - specifying a group to lanes.linda() is mandatory when Lanes is configured with user Keepers. |
@@ -35,7 +36,7 @@ CHANGE 2: BGe 11-Jun-24 | |||
35 | - deep userdata are an acceptable key to send data into (for example, another linda). | 36 | - deep userdata are an acceptable key to send data into (for example, another linda). |
36 | - Lane generator settings: | 37 | - Lane generator settings: |
37 | - error_trace_level added. Replaces the global verbose_errors setting. | 38 | - error_trace_level added. Replaces the global verbose_errors setting. |
38 | - name added. Can be used to set the name early (before the lane body calls set_debug_threadname()). | 39 | - name added. Can be used to set the name early (before the lane body calls lane_threadname()). |
39 | * Internal changes | 40 | * Internal changes |
40 | - Lanes is implemented in C++20: thread, condition_variable, mutex, string_view, variant, and more! | 41 | - Lanes is implemented in C++20: thread, condition_variable, mutex, string_view, variant, and more! |
41 | - Almost all platform-specific code is gone (only a small bit for thread priority and affinity remains). | 42 | - Almost all platform-specific code is gone (only a small bit for thread priority and affinity remains). |
diff --git a/docs/index.html b/docs/index.html index 0cdf954..4fd7447 100644 --- a/docs/index.html +++ b/docs/index.html | |||
@@ -736,7 +736,7 @@ | |||
736 | </td> | 736 | </td> |
737 | <td>string</td> | 737 | <td>string</td> |
738 | <td> | 738 | <td> |
739 | Name of the lane. If <tt>"auto"</tt>, name is built from <tt>ar.short_src:ar.linedefined</tt>. Can be changed later from the inside of the lane with <tt>set_debug_threadname()</tt> (see below). | 739 | Name of the lane. If <tt>"auto"</tt>, name is built from <tt>ar.short_src:ar.linedefined</tt>. Can be changed later from the inside of the lane with <tt>lane_threadname()</tt> (see below). |
740 | </td> | 740 | </td> |
741 | </tr> | 741 | </tr> |
742 | <tr id=".gc_cb" valign=top> | 742 | <tr id=".gc_cb" valign=top> |
@@ -773,7 +773,7 @@ | |||
773 | </table> | 773 | </table> |
774 | 774 | ||
775 | <p> | 775 | <p> |
776 | Each lane gets a global function <tt>set_debug_threadname()</tt> that it can use anytime to do as the name says. Supported debuggers are Microsoft Visual Studio (for the C side) and <a href="https://github.com/unknownworlds/decoda">Decoda</a> (for the Lua side).<br /> | 776 | Each lane gets a global function <tt>lane_threadname()</tt> that it can use anytime to do both read and change the thread name. Supported debuggers are Microsoft Visual Studio (for the C side) and <a href="https://github.com/unknownworlds/decoda">Decoda</a> (for the Lua side).<br /> |
777 | Change <tt>HAVE_DECODA_SUPPORT()</tt> in <tt>lanesconf.h</tt> to enable the Decoda support, that sets a special global variable <tt>decoda_name</tt> in the lane's state.<br /> | 777 | Change <tt>HAVE_DECODA_SUPPORT()</tt> in <tt>lanesconf.h</tt> to enable the Decoda support, that sets a special global variable <tt>decoda_name</tt> in the lane's state.<br /> |
778 | The name is stored inside the Lua state registry so that it is available for error reporting. Changing <tt>decoda_name</tt> doesn't affect this hidden name or the OS thread name reported by MSVC.<br /> | 778 | The name is stored inside the Lua state registry so that it is available for error reporting. Changing <tt>decoda_name</tt> doesn't affect this hidden name or the OS thread name reported by MSVC.<br /> |
779 | When Lanes is initialized by the first <a href="#initialization"><tt>lanes.configure()</tt></a> call, <tt>"main"</tt> is stored in the registry in the same fashion (but <tt>decoda_name</tt> and the OS thread name are left unchanged).<br /> | 779 | When Lanes is initialized by the first <a href="#initialization"><tt>lanes.configure()</tt></a> call, <tt>"main"</tt> is stored in the registry in the same fashion (but <tt>decoda_name</tt> and the OS thread name are left unchanged).<br /> |
diff --git a/src/lane.cpp b/src/lane.cpp index dd038a3..8c4062c 100644 --- a/src/lane.cpp +++ b/src/lane.cpp | |||
@@ -44,11 +44,12 @@ static constexpr UniqueKey kCachedTostring{ 0xAB5EA23BCEA0C35Cull }; | |||
44 | // ################################################################################################# | 44 | // ################################################################################################# |
45 | // ################################################################################################# | 45 | // ################################################################################################# |
46 | 46 | ||
47 | // lane:get_debug_threadname() | ||
47 | static LUAG_FUNC(get_debug_threadname) | 48 | static LUAG_FUNC(get_debug_threadname) |
48 | { | 49 | { |
49 | Lane* const _lane{ ToLane(L_, 1) }; | 50 | Lane* const _lane{ ToLane(L_, 1) }; |
50 | luaL_argcheck(L_, lua_gettop(L_) == 1, 2, "too many arguments"); | 51 | luaL_argcheck(L_, lua_gettop(L_) == 1, 2, "too many arguments"); |
51 | luaG_pushstring(L_, _lane->debugName); | 52 | luaG_pushstring(L_, _lane->getDebugName()); |
52 | return 1; | 53 | return 1; |
53 | } | 54 | } |
54 | 55 | ||
@@ -78,17 +79,26 @@ static LUAG_FUNC(set_finalizer) | |||
78 | 79 | ||
79 | // ################################################################################################# | 80 | // ################################################################################################# |
80 | 81 | ||
82 | // serves both to read and write the name from the inside of the lane | ||
81 | // upvalue #1 is the lane userdata | 83 | // upvalue #1 is the lane userdata |
82 | static LUAG_FUNC(set_debug_threadname) | 84 | // this function is exported in a lane's state, therefore it is callable only from inside the Lane's state |
85 | static LUAG_FUNC(lane_threadname) | ||
83 | { | 86 | { |
84 | // C s_lane structure is a light userdata upvalue | 87 | // C s_lane structure is a light userdata upvalue |
85 | Lane* const _lane{ luaG_tolightuserdata<Lane>(L_, lua_upvalueindex(1)) }; | 88 | Lane* const _lane{ luaG_tolightuserdata<Lane>(L_, lua_upvalueindex(1)) }; |
86 | LUA_ASSERT(L_, L_ == _lane->L); // this function is exported in a lane's state, therefore it is callable only from inside the Lane's state | 89 | LUA_ASSERT(L_, L_ == _lane->L); // this function is exported in a lane's state, therefore it is callable only from inside the Lane's state |
87 | lua_settop(L_, 1); | 90 | if (lua_gettop(L_) == 1) { |
88 | STACK_CHECK_START_REL(L_, 0); | 91 | lua_settop(L_, 1); |
89 | _lane->changeDebugName(-1); | 92 | STACK_CHECK_START_REL(L_, 0); |
90 | STACK_CHECK(L_, 0); | 93 | _lane->changeDebugName(-1); |
91 | return 0; | 94 | STACK_CHECK(L_, 0); |
95 | return 0; | ||
96 | } else if (lua_gettop(L_) == 0) { | ||
97 | luaG_pushstring(L_, _lane->getDebugName()); | ||
98 | return 1; | ||
99 | } else { | ||
100 | raise_luaL_error(L_, "Wrong number of arguments"); | ||
101 | } | ||
92 | } | 102 | } |
93 | 103 | ||
94 | // ################################################################################################# | 104 | // ################################################################################################# |
@@ -339,7 +349,7 @@ static int thread_index_number(lua_State* L_) | |||
339 | lua_replace(L_, -3); // L_: lane n error() "error" | 349 | lua_replace(L_, -3); // L_: lane n error() "error" |
340 | lua_pushinteger(L_, 3); // L_: lane n error() "error" 3 | 350 | lua_pushinteger(L_, 3); // L_: lane n error() "error" 3 |
341 | lua_call(L_, 2, 0); // error(tostring(errstring), 3) -> doesn't return // L_: lane n | 351 | lua_call(L_, 2, 0); // error(tostring(errstring), 3) -> doesn't return // L_: lane n |
342 | raise_luaL_error(L_, "%s: should not get here!", _lane->debugName.data()); | 352 | raise_luaL_error(L_, "%s: should not get here!", _lane->getDebugName().data()); |
343 | } else { | 353 | } else { |
344 | lua_pop(L_, 1); // L_: lane n {uv} | 354 | lua_pop(L_, 1); // L_: lane n {uv} |
345 | } | 355 | } |
@@ -416,7 +426,7 @@ static LUAG_FUNC(thread_index) | |||
416 | lua_call(L_, 1, 1); // L_: mt error() "Unknown key: " "k" | 426 | lua_call(L_, 1, 1); // L_: mt error() "Unknown key: " "k" |
417 | lua_concat(L_, 2); // L_: mt error() "Unknown key: <k>" | 427 | lua_concat(L_, 2); // L_: mt error() "Unknown key: <k>" |
418 | lua_call(L_, 1, 0); // error( "Unknown key: " .. key) -> doesn't return // L_: mt | 428 | lua_call(L_, 1, 0); // error( "Unknown key: " .. key) -> doesn't return // L_: mt |
419 | raise_luaL_error(L_, "%s[%s]: should not get here!", _lane->debugName.data(), luaG_typename(L_, kKey).data()); | 429 | raise_luaL_error(L_, "%s[%s]: should not get here!", _lane->getDebugName().data(), luaG_typename(L_, kKey).data()); |
420 | } | 430 | } |
421 | } | 431 | } |
422 | 432 | ||
@@ -716,11 +726,11 @@ static void PrepareLaneHelpers(Lane* lane_) | |||
716 | tools::PopulateFuncLookupTable(_L, -1, "set_finalizer"); | 726 | tools::PopulateFuncLookupTable(_L, -1, "set_finalizer"); |
717 | lua_setglobal(_L, "set_finalizer"); | 727 | lua_setglobal(_L, "set_finalizer"); |
718 | 728 | ||
719 | // Tie "set_debug_threadname()" to the state | 729 | // Tie "lane_threadname()" to the state |
720 | // But don't register it in the lookup database because of the Lane pointer upvalue | 730 | // But don't register it in the lookup database because of the Lane pointer upvalue |
721 | lua_pushlightuserdata(_L, lane_); | 731 | lua_pushlightuserdata(_L, lane_); |
722 | lua_pushcclosure(_L, LG_set_debug_threadname, 1); | 732 | lua_pushcclosure(_L, LG_lane_threadname, 1); |
723 | lua_setglobal(_L, "set_debug_threadname"); | 733 | lua_setglobal(_L, "lane_threadname"); |
724 | 734 | ||
725 | // Tie "cancel_test()" to the state | 735 | // Tie "cancel_test()" to the state |
726 | lua_pushcfunction(_L, LG_cancel_test); | 736 | lua_pushcfunction(_L, LG_cancel_test); |
@@ -860,7 +870,7 @@ static LUAG_FUNC(lane_gc) | |||
860 | lua_rawget(L_, -2); // L_: ud uservalue gc_cb|nil | 870 | lua_rawget(L_, -2); // L_: ud uservalue gc_cb|nil |
861 | if (!lua_isnil(L_, -1)) { | 871 | if (!lua_isnil(L_, -1)) { |
862 | lua_remove(L_, -2); // L_: ud gc_cb|nil | 872 | lua_remove(L_, -2); // L_: ud gc_cb|nil |
863 | luaG_pushstring(L_, _lane->debugName); // L_: ud gc_cb name | 873 | luaG_pushstring(L_, _lane->getDebugName()); // L_: ud gc_cb name |
864 | _have_gc_cb = true; | 874 | _have_gc_cb = true; |
865 | } else { | 875 | } else { |
866 | lua_pop(L_, 2); // L_: ud | 876 | lua_pop(L_, 2); // L_: ud |
@@ -879,8 +889,6 @@ static LUAG_FUNC(lane_gc) | |||
879 | } else if (_lane->L) { | 889 | } else if (_lane->L) { |
880 | // no longer accessing the Lua VM: we can close right now | 890 | // no longer accessing the Lua VM: we can close right now |
881 | _lane->closeState(); | 891 | _lane->closeState(); |
882 | // just in case, but _lane will be freed soon so... | ||
883 | _lane->debugName = std::string_view{ "<gc>" }; | ||
884 | } | 892 | } |
885 | 893 | ||
886 | // Clean up after a (finished) thread | 894 | // Clean up after a (finished) thread |
@@ -1003,7 +1011,10 @@ void Lane::changeDebugName(int const nameIdx_) | |||
1003 | // store a hidden reference in the registry to make sure the string is kept around even if a lane decides to manually change the "decoda_name" global... | 1011 | // store a hidden reference in the registry to make sure the string is kept around even if a lane decides to manually change the "decoda_name" global... |
1004 | kLaneNameRegKey.setValue(L, [idx = _nameIdx](lua_State* L_) { lua_pushvalue(L_, idx); }); // L: ... "name" ... | 1012 | kLaneNameRegKey.setValue(L, [idx = _nameIdx](lua_State* L_) { lua_pushvalue(L_, idx); }); // L: ... "name" ... |
1005 | // keep a direct pointer on the string | 1013 | // keep a direct pointer on the string |
1006 | debugName = luaG_tostring(L, _nameIdx); | 1014 | { |
1015 | std::lock_guard<std::mutex> _guard{ debugNameMutex }; | ||
1016 | debugName = luaG_tostring(L, _nameIdx); | ||
1017 | } | ||
1007 | if constexpr (HAVE_DECODA_SUPPORT()) { | 1018 | if constexpr (HAVE_DECODA_SUPPORT()) { |
1008 | // to see VM name in Decoda debugger Virtual Machine window | 1019 | // to see VM name in Decoda debugger Virtual Machine window |
1009 | lua_pushvalue(L, _nameIdx); // L: ... "name" ... "name" | 1020 | lua_pushvalue(L, _nameIdx); // L: ... "name" ... "name" |
@@ -1119,7 +1130,10 @@ void Lane::securizeDebugName(lua_State* L_) | |||
1119 | LUA_ASSERT(L_, lua_istable(L_, -1)); | 1130 | LUA_ASSERT(L_, lua_istable(L_, -1)); |
1120 | // we don't care about the actual key, so long as it's unique and can't collide with anything. | 1131 | // we don't care about the actual key, so long as it's unique and can't collide with anything. |
1121 | lua_newtable(L_); // L_: lane ... {uv} {} | 1132 | lua_newtable(L_); // L_: lane ... {uv} {} |
1122 | debugName = luaG_pushstring(L_, debugName); // L_: lane ... {uv} {} name | 1133 | { |
1134 | std::lock_guard<std::mutex> _guard{ debugNameMutex }; | ||
1135 | debugName = luaG_pushstring(L_, debugName); // L_: lane ... {uv} {} name | ||
1136 | } | ||
1123 | lua_rawset(L_, -3); // L_: lane ... {uv} | 1137 | lua_rawset(L_, -3); // L_: lane ... {uv} |
1124 | lua_pop(L_, 1); // L_: lane | 1138 | lua_pop(L_, 1); // L_: lane |
1125 | STACK_CHECK(L_, 0); | 1139 | STACK_CHECK(L_, 0); |
@@ -89,8 +89,13 @@ class Lane | |||
89 | // M: sub-thread OS thread | 89 | // M: sub-thread OS thread |
90 | // S: not used | 90 | // S: not used |
91 | 91 | ||
92 | private: | ||
93 | |||
94 | mutable std::mutex debugNameMutex; | ||
92 | std::string_view debugName{ "<unnamed>" }; | 95 | std::string_view debugName{ "<unnamed>" }; |
93 | 96 | ||
97 | public: | ||
98 | |||
94 | Universe* const U{}; | 99 | Universe* const U{}; |
95 | lua_State* S{}; // the master state of the lane | 100 | lua_State* S{}; // the master state of the lane |
96 | lua_State* L{}; // the state we run things in (either S or a lua_newthread() state if we run in coroutine mode) | 101 | lua_State* L{}; // the state we run things in (either S or a lua_newthread() state if we run in coroutine mode) |
@@ -143,12 +148,21 @@ class Lane | |||
143 | void changeDebugName(int const nameIdx_); | 148 | void changeDebugName(int const nameIdx_); |
144 | void closeState() | 149 | void closeState() |
145 | { | 150 | { |
151 | { | ||
152 | std::lock_guard<std::mutex> _guard{ debugNameMutex }; | ||
153 | debugName = std::string_view{ "<gc>" }; | ||
154 | } | ||
146 | lua_State* _L{ S }; | 155 | lua_State* _L{ S }; |
147 | S = nullptr; | 156 | S = nullptr; |
148 | L = nullptr; | 157 | L = nullptr; |
149 | lua_close(_L); // this collects our coroutine thread at the same time | 158 | lua_close(_L); // this collects our coroutine thread at the same time |
150 | } | 159 | } |
151 | [[nodiscard]] std::string_view errorTraceLevelString() const; | 160 | [[nodiscard]] std::string_view errorTraceLevelString() const; |
161 | [[nodiscard]] std::string_view getDebugName() const | ||
162 | { | ||
163 | std::lock_guard<std::mutex> _guard{ debugNameMutex }; | ||
164 | return debugName; | ||
165 | } | ||
152 | [[nodiscard]] int pushErrorHandler() const; | 166 | [[nodiscard]] int pushErrorHandler() const; |
153 | [[nodiscard]] std::string_view pushErrorTraceLevel(lua_State* L_) const; | 167 | [[nodiscard]] std::string_view pushErrorTraceLevel(lua_State* L_) const; |
154 | static void PushMetatable(lua_State* L_); | 168 | static void PushMetatable(lua_State* L_); |
diff --git a/src/tracker.cpp b/src/tracker.cpp index 05902c9..16c9c55 100644 --- a/src/tracker.cpp +++ b/src/tracker.cpp | |||
@@ -94,7 +94,7 @@ void LaneTracker::tracking_add(Lane* lane_) | |||
94 | while (_lane != TRACKING_END) { | 94 | while (_lane != TRACKING_END) { |
95 | // insert a { name='<name>', status='<status>' } tuple, so that several lanes with the same name can't clobber each other | 95 | // insert a { name='<name>', status='<status>' } tuple, so that several lanes with the same name can't clobber each other |
96 | lua_createtable(L_, 0, 2); // L_: {} {} | 96 | lua_createtable(L_, 0, 2); // L_: {} {} |
97 | luaG_pushstring(L_, _lane->debugName); // L_: {} {} "name" | 97 | luaG_pushstring(L_, _lane->getDebugName()); // L_: {} {} "name" |
98 | lua_setfield(L_, -2, "name"); // L_: {} {} | 98 | lua_setfield(L_, -2, "name"); // L_: {} {} |
99 | _lane->pushStatusString(L_); // L_: {} {} "<status>" | 99 | _lane->pushStatusString(L_); // L_: {} {} "<status>" |
100 | lua_setfield(L_, -2, "status"); // L_: {} {} | 100 | lua_setfield(L_, -2, "status"); // L_: {} {} |
diff --git a/tests/basic.lua b/tests/basic.lua index 97783cb..f44c75f 100644 --- a/tests/basic.lua +++ b/tests/basic.lua | |||
@@ -76,7 +76,7 @@ end | |||
76 | PRINT("\n\n", "---=== Tasking (basic) ===---", "\n\n") | 76 | PRINT("\n\n", "---=== Tasking (basic) ===---", "\n\n") |
77 | 77 | ||
78 | local function task(a, b, c) | 78 | local function task(a, b, c) |
79 | set_debug_threadname("task("..a..","..b..","..c..")") | 79 | lane_threadname("task("..a..","..b..","..c..")") |
80 | --error "111" -- testing error messages | 80 | --error "111" -- testing error messages |
81 | assert(hey) | 81 | assert(hey) |
82 | local v=0 | 82 | local v=0 |
@@ -329,7 +329,7 @@ SLEEP(1) | |||
329 | PRINT("\n\n", "---=== Stdlib naming ===---", "\n\n") | 329 | PRINT("\n\n", "---=== Stdlib naming ===---", "\n\n") |
330 | 330 | ||
331 | local function dump_g(_x) | 331 | local function dump_g(_x) |
332 | set_debug_threadname "dump_g" | 332 | lane_threadname "dump_g" |
333 | assert(print) | 333 | assert(print) |
334 | print("### dumping _G for '" .. _x .. "'") | 334 | print("### dumping _G for '" .. _x .. "'") |
335 | for k, v in pairs(_G) do | 335 | for k, v in pairs(_G) do |
@@ -339,7 +339,7 @@ local function dump_g(_x) | |||
339 | end | 339 | end |
340 | 340 | ||
341 | local function io_os_f(_x) | 341 | local function io_os_f(_x) |
342 | set_debug_threadname "io_os_f" | 342 | lane_threadname "io_os_f" |
343 | assert(print) | 343 | assert(print) |
344 | print("### checking io and os libs existence for '" .. _x .. "'") | 344 | print("### checking io and os libs existence for '" .. _x .. "'") |
345 | assert(io) | 345 | assert(io) |
@@ -348,7 +348,7 @@ local function io_os_f(_x) | |||
348 | end | 348 | end |
349 | 349 | ||
350 | local function coro_f(_x) | 350 | local function coro_f(_x) |
351 | set_debug_threadname "coro_f" | 351 | lane_threadname "coro_f" |
352 | assert(print) | 352 | assert(print) |
353 | print("### checking coroutine lib existence for '" .. _x .. "'") | 353 | print("### checking coroutine lib existence for '" .. _x .. "'") |
354 | assert(coroutine) | 354 | assert(coroutine) |
@@ -388,7 +388,7 @@ PRINT("\n\n", "---=== Comms criss cross ===---", "\n\n") | |||
388 | -- | 388 | -- |
389 | local tc= lanes_gen("io", {gc_cb = gc_cb}, | 389 | local tc= lanes_gen("io", {gc_cb = gc_cb}, |
390 | function(linda, ch_in, ch_out) | 390 | function(linda, ch_in, ch_out) |
391 | set_debug_threadname("criss cross " .. ch_in .. " -> " .. ch_out) | 391 | lane_threadname("criss cross " .. ch_in .. " -> " .. ch_out) |
392 | local function STAGE(str) | 392 | local function STAGE(str) |
393 | io.stderr:write(ch_in..": "..str.."\n") | 393 | io.stderr:write(ch_in..": "..str.."\n") |
394 | linda:send(nil, ch_out, str) | 394 | linda:send(nil, ch_out, str) |
@@ -488,7 +488,7 @@ PRINT("\n\n", "---=== :join test ===---", "\n\n") | |||
488 | 488 | ||
489 | local S= lanes_gen("table", {gc_cb = gc_cb}, | 489 | local S= lanes_gen("table", {gc_cb = gc_cb}, |
490 | function(arg) | 490 | function(arg) |
491 | set_debug_threadname "join test lane" | 491 | lane_threadname "join test lane" |
492 | set_finalizer(function() end) | 492 | set_finalizer(function() end) |
493 | aux= {} | 493 | aux= {} |
494 | for i, v in ipairs(arg) do | 494 | for i, v in ipairs(arg) do |
diff --git a/tests/cancel.lua b/tests/cancel.lua index 1724e6a..9ee986c 100644 --- a/tests/cancel.lua +++ b/tests/cancel.lua | |||
@@ -75,7 +75,7 @@ end | |||
75 | 75 | ||
76 | local laneBody = function( mode_, payload_) | 76 | local laneBody = function( mode_, payload_) |
77 | local name = "laneBody("..tostring(mode_)..","..tostring(payload_)..")" | 77 | local name = "laneBody("..tostring(mode_)..","..tostring(payload_)..")" |
78 | set_debug_threadname( name) | 78 | lane_threadname(name) |
79 | 79 | ||
80 | set_finalizer( function( err, stk) | 80 | set_finalizer( function( err, stk) |
81 | if err == lanes.cancel_error then | 81 | if err == lanes.cancel_error then |
diff --git a/tests/deadlock.lua b/tests/deadlock.lua index bbbda8d..d028e83 100644 --- a/tests/deadlock.lua +++ b/tests/deadlock.lua | |||
@@ -22,7 +22,7 @@ if do_extra_stuff then | |||
22 | 22 | ||
23 | -- lane generator. don't initialize "io" base library so that it is not known in the lane | 23 | -- lane generator. don't initialize "io" base library so that it is not known in the lane |
24 | local g = lanes.gen('base,table', function() | 24 | local g = lanes.gen('base,table', function() |
25 | set_debug_threadname( "deadlock_lane") | 25 | lane_threadname( "deadlock_lane") |
26 | -- wrapping inside pcall makes the Lanes module unaware that something went wrong | 26 | -- wrapping inside pcall makes the Lanes module unaware that something went wrong |
27 | print( "In lane 1:", table_unpack{ pcall( linda.receive, linda, 'tmp')}) | 27 | print( "In lane 1:", table_unpack{ pcall( linda.receive, linda, 'tmp')}) |
28 | -- with the bug not fixed, and non-recursive mutexes, we can hang here | 28 | -- with the bug not fixed, and non-recursive mutexes, we can hang here |
diff --git a/tests/fibonacci.lua b/tests/fibonacci.lua index 51e7137..7885ae6 100644 --- a/tests/fibonacci.lua +++ b/tests/fibonacci.lua | |||
@@ -24,14 +24,14 @@ end | |||
24 | local KNOWN= { [0]=0, 1,1,2,3,5,8,13,21,34,55,89,144 } | 24 | local KNOWN= { [0]=0, 1,1,2,3,5,8,13,21,34,55,89,144 } |
25 | 25 | ||
26 | -- dummy function so that we don't error when fib() is launched from the master state | 26 | -- dummy function so that we don't error when fib() is launched from the master state |
27 | set_debug_threadname = function ( ...) | 27 | lane_threadname = function ( ...) |
28 | end | 28 | end |
29 | 29 | ||
30 | -- | 30 | -- |
31 | -- uint= fib( n_uint ) | 31 | -- uint= fib( n_uint ) |
32 | -- | 32 | -- |
33 | local function fib( n ) | 33 | local function fib( n ) |
34 | set_debug_threadname( "fib(" .. n .. ")") | 34 | lane_threadname( "fib(" .. n .. ")") |
35 | local lanes = require"lanes" | 35 | local lanes = require"lanes" |
36 | -- | 36 | -- |
37 | local sum | 37 | local sum |
diff --git a/tests/track_lanes.lua b/tests/track_lanes.lua index 32f579b..803fae5 100644 --- a/tests/track_lanes.lua +++ b/tests/track_lanes.lua | |||
@@ -29,11 +29,11 @@ local sleeper = function( name_, seconds_) | |||
29 | end | 29 | end |
30 | -- print( "entering '" .. name_ .. "'") | 30 | -- print( "entering '" .. name_ .. "'") |
31 | local lanes = require "lanes" | 31 | local lanes = require "lanes" |
32 | -- no set_debug_threadname in main thread | 32 | -- no lane_threadname in main thread |
33 | if set_debug_threadname | 33 | if lane_threadname |
34 | then | 34 | then |
35 | -- print( "set_debug_threadname('" .. name_ .. "')") | 35 | -- print( "lane_threadname('" .. name_ .. "')") |
36 | set_debug_threadname( name_) | 36 | lane_threadname( name_) |
37 | end | 37 | end |
38 | -- suspend the lane for the specified duration | 38 | -- suspend the lane for the specified duration |
39 | lanes.sleep(seconds_) | 39 | lanes.sleep(seconds_) |