From fa89fef9db0435b4e2c017a1aa67f1b2467a07da Mon Sep 17 00:00:00 2001
From: Benoit Germain
Date: Mon, 21 Apr 2025 13:54:07 +0200
Subject: Documentation improvements
* added an API cheat sheet
* improved documentation for lane:cancel()
---
docs/index.html | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 88 insertions(+), 10 deletions(-)
diff --git a/docs/index.html b/docs/index.html
index 116fc0a..3dfac70 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -38,6 +38,7 @@
Description ·
Supported systems ·
Building and Installing ·
+ API Cheat sheet
Embedding
@@ -70,7 +71,7 @@
- This document was revised on 18-Apr-25, and applies to version 4.0.0.
+ This document was revised on 21-Apr-25, and applies to version 4.0.0.
@@ -169,6 +170,82 @@
+
+
+ API Cheat sheet
+
+ -
+ require "lanes": to require Lanes
+
+ -
+ The lanes module
+
+ - lanes.cancel_error: a special error value returned from cancelled lanes
+ - lanes.collectgarbage(): o trigger a GC cycle in all Keeper states
+ - lanes.configure(): to configure Lanes
+ - lanes.coro(): to start a coroutine-like lane
+ - lanes.finally(): to install a function called on Lanes shutdown
+ - lanes.gen(): to start a lane as a regular function
+ - lanes.genactomic(): to obtain an atomic counter
+ - lanes.genlock(): to obtain an atomic-like data stack
+ - lanes.linda(): to create a Linda
+ - lanes.nameof(): to find where a value exists
+ - lanes.now_secs(): to obtain the current clock value
+ - lanes.register(): to scan modules so that functions using them can be transferred
+ - lanes.set_thread_priority(): to change thread priority
+ - lanes.set_thread_affinity(): to change thread affinity
+ - lanes.threads(): to obtain a list of all lanes
+ - lanes.sleep(): to sleep for a given duration
+ - lanes.timer(): to start a timer
+ - lanes.timers(): to list active timers
+
+
+ -
+ Given some lane handle lane_h
+
+ - lane_h[]: to wait for, and read the values returned by the lane
+ - lane_h:cancel(): to request the lane to stop running
+ - lane_h.error_trace_level: current setting of error logging level
+ - lane_h:get_threadname(): to read the thread name
+ - lane_h:join(): to wait for the lane to terminate (or yield)
+ - lane_h:resume(): to resume a coroutine Lane
+ - lane_h.status: current status of the lane
+
+
+ -
+ Inside the lane
+
+ - lane_threadname(): to read or change the name of the thread
+ - set_finalizer(): to install a function called when the lane exits
+
+
+ -
+ Given some Linda l
+
+ - l:cancel(): to mark a Linda for cancellation
+ - l:collectgarbage(): to trigger a GC cycle in the Linda's Keeper state
+ - l:deep(): returns a light userdata uniquely representing the Linda
+ - l:dump(): to have information about slot contents
+ - l:count(): to count data items
+ - l:get(): to read data without consuming it
+ - l:limit(): to cap the amount of transiting data
+ - l:receive(): to read one item of data from multiple slots
+ - l:receive_batched(): to to read several item of data from a single slot
+ - l:restrict(): to place a restraint on the operations that can be done
+ - l:send(): to append data
+ - l:set(): to replace the data
+ - l:wake(): to manually wake blocking calls
+
+
+ -
+ embedding
+
+ - luaopen_lanes_embedded: to manually initialize Lanes
+
+
+
+
+
Embedding
@@ -1137,14 +1214,17 @@
- timeout is an optional number >= 0. Defaults to infinite if left unspecified or nil.
-
cancel() sends a cancellation request to the lane.
-
- First argument is a mode can be one of:
+
+ Returns true, lane_h.status if lane was already done (in "done", "error" or "cancelled" status), or the cancellation was fruitful within timeout_secs timeout period.
+ Returns false, "timeout" otherwise.
+
+ First argument is a mode. It can be one of:
-
"soft": Cancellation will only cause cancel_test() to return true, so that the lane can cleanup manually.
+
+ Lindas will also check for cancellation inside blocking calls to early out based on their wake_period.
-
"hard": waits for the request to be processed, or a timeout to occur. linda operations detecting the cancellation request will raise a special cancellation error (meaning they won't return in that case).
@@ -1160,15 +1240,13 @@
If mode is not specified, it defaults to "hard".
If wake_lane is true, the lane is also signalled so that execution returns from any pending linda operation. linda operations detecting the cancellation request return lanes.cancel_error.
-
- Returns true, lane_h.status if lane was already done (in "done", "error" or "cancelled" status), or the cancellation was fruitful within timeout_secs timeout period.
- Returns false, "timeout" otherwise.
-
+timeout is an optional number >= 0. Defaults to infinite if left unspecified or nil.
+
If the lane is still running after the timeout expired, there is a chance lanes will freeze forever at shutdown when failing to terminate all free-running lanes within the specified timeout.
- Cancellation is tested before going to sleep in receive() or send() calls and after executing cancelstep Lua statements. A pending receive()or send() call is awakened.
+ Cancellation is tested before going to sleep in receive(), receive_batched() or send() calls and after executing cancelstep Lua statements. A pending receive()or send() call is awakened.
This means the execution of the lane will resume although the operation has not completed, to give the lane a chance to detect cancellation (even in the case the code waits on a linda with infinite timeout).
--
cgit v1.2.3-55-g6feb