From dc55ffcf9cf3592b822bbdb90b63c72ed61ec668 Mon Sep 17 00:00:00 2001
From: Benoit Germain
The name is stored inside the Lua state registry so that it is available for error reporting. Changing decoda_name doesn't affect this hidden name or the OS thread name reported by MSVC.
When Lanes is initialized by the first lanes.configure() call, "main" is stored in the registry in the same fashion (but decoda_name and the OS thread name are left unchanged).
- The lane also has a method lane:get_debug_threadname() that gives access to that name from the caller side (returns "<unnamed>" if unset, "<closed>" if the internal Lua state is closed).
+ The lane also has a method lane:get_threadname() that gives access to that name from the caller side (returns "<unnamed>" if unset, "<closed>" if the internal Lua state is closed).
With Lua 5.4, Lanes have a __close metamethod, meaning they can be declared to-be-closed. __close calls lane:join(nil).
+ It is possible to have the Lane body run inside the lane as a coroutine. For this, just use lanes.coro() instead of lanes.gen(). + +
+ local lane_h = lanes.coro(...)(...)+ |
+
+ local yielded_values = lane_h:resume(reply_values...)+ |
+
@@ -873,7 +899,7 @@
- The current execution state of a lane can be read via its status member, providing one of these values: (2) + The current execution state of a lane can be read via its status member, providing one of these values:
- running, not suspended on a Linda call. + Running, not suspended on a Linda call, or yielded on a coroutine.yield() call. + | +|||
+ | + + "suspended" + + | ++ | + Coroutine lane stopped at a coroutine.yield() point. + | +
+ | + + "resuming" + + | ++ | + Parent state called lane_h:resume() on a suspended coroutine lane, but the lane hasn't yet actually resumed execution. |
- waiting at a Linda :receive() or :send() + Waiting at a Linda :receive() or :send() | |||
- finished executing (results are ready) + Finished executing (results are ready) | |||
- met an error (reading results will propagate it) + Met an error (reading results will propagate it) | |||
- received cancellation and finished itself. + Received cancellation and finished itself. |
- Makes sure lane has finished, and gives its first (maybe only) return value. Other return values will be available in other lane_h indices.
+ Makes sure lane has finished or yielded, and gives its first (maybe only) return value. Other return values will be available in other lane_h indices.
If the lane ended in an error, it is propagated to master state at this place.
- Waits until the lane finishes, or timeout seconds have passed (forever if nil).
+ Waits until the lane finishes/yields, or timeout seconds have passed (forever if nil).
Unlike in reading the results in table fashion, errors are not propagated.
Possible return values are:
- Lanes registers a function set_finalizer in the lane's Lua state for doing this. + Lanes registers a function set_finalizer() in the lane's Lua state for doing this. Any functions given to it will be called in the lane Lua state, just prior to closing it. It is possible to set more than one finalizer. They are not called in any particular order.
-- cgit v1.2.3-55-g6feb