From 4f97720e4c3944ccf9b9742028dc697c2dd94c5a Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Thu, 26 Feb 2026 11:02:55 +0100 Subject: change cancel_test() to raise cancel_error on hard-cancels by default --- docs/index.html | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'docs') diff --git a/docs/index.html b/docs/index.html index 3dc2b61..11ed3eb 100644 --- a/docs/index.html +++ b/docs/index.html @@ -65,13 +65,13 @@


- Copyright © 2007-25 Asko Kauppi, Benoit Germain. All rights reserved. + Copyright © 2007-26 Asko Kauppi, Benoit Germain. All rights reserved.
Lua Lanes is published under the same MIT license as Lua 5.1, 5.2, 5.3, 5.4 and 5.5.

- This document was revised on 29-Sep-2025, and applies to version 4.0.0. + This document was revised on 26-Feb-2026, and applies to version 4.0.0.

@@ -1200,7 +1200,7 @@
  • "extended": stack_tbl is an array of tables containing info gathered with lua_getinfo() ("source","currentline","name","namewhat","what").
  • -
  • nil, "killed" if forcefully killed.
  • +
  • nil, lanes.cancel_error if "hard"-cancelled during a linda operation (which is nothing more than a special case of the above).
  • true [, returned-values]: The return values of the lane function.
  • If the lane handle obtained from lanes.gen() is to-be-closed, closing the value will cause a call to join(). @@ -1262,14 +1262,14 @@
  • "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).
    - If the lane isn't actually waiting on a linda when the request is issued, a lane calling cancel_test() will see it return "hard". + If the lane isn't actually waiting on a linda when the request is issued, a lane calling cancel_test() will also raise lanes.cancel_error, unless cancel_test(true) is used, in which case it returns "hard" instead.
    - wake_lane defaults to true, and timeout defaults to 0 if not specified. + wake_lane defaults to true, and timeout defaults to infinite if not specified.
  • "call", "ret", "line", "count": Asynchronously install the corresponding hook, then behave as "hard".
    - If the lane has the opportunity to call cancel_test() before the hook is invoked, calling cancel_test() will see it return "hard". + If the lane has the opportunity to call cancel_test() before the hook is invoked, it will also raise lanes.cancel_error (or return "hard" if cancel_test(true) is used).
  • "all": Installs all hooks in one shot, just to be sure. @@ -1297,10 +1297,15 @@

    -	false|"soft"|"hard" = cancel_test() -- inside the lane
    +	false|"soft" = cancel_test()        -- raises cancel_error on hard cancel
    +	false|"soft"|"hard" = cancel_test(true) -- returns "hard" instead of raising
     

    Lanes installs the function cancel_test() in each created lane to manually test for cancel requests. + It returns false when no cancel is pending, "soft" on a soft cancel request, and raises + lanes.cancel_error on a hard cancel request. Passing true as the optional argument suppresses + the raise and returns "hard" instead, which is useful when the lane needs to distinguish the cancel + mode before deciding how to react.

    -- cgit v1.2.3-55-g6feb