From 96daea993eeea17f0c64325491943e48795ff751 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Mon, 8 Apr 2024 16:57:53 +0200 Subject: C++ migration: use std::jthread, std::condition_variable, std::chrono. win32 pthread support is gone new setting configure.shutdown_mode for cancellation of free-running threads at shutdown. no more hard thread termination! If a thread doesn't cooperate, an error is raised. lane.status "killed" is gone lane:cancel can't force-kill. --- docs/index.html | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) (limited to 'docs') diff --git a/docs/index.html b/docs/index.html index ee5acfa..d24d3d7 100644 --- a/docs/index.html +++ b/docs/index.html @@ -425,7 +425,18 @@ number >= 0 - Sets the duration in seconds Lanes will wait for graceful termination of running lanes at application shutdown. Irrelevant for builds using pthreads. Default is 0.25. + Sets the duration in seconds Lanes will wait for graceful termination of running lanes at application shutdown. Default is 0.25. + + + + + .shutdown_mode + + + "hard"/"soft"/"call"/"ret"/"line"/"count" + + + Select the cancellation mode used at Lanes shutdown to request free running lane termination. See lane cancellation. Default is "hard". @@ -875,16 +886,6 @@ received cancellation and finished itself. - - - - "killed" - - - - was forcefully killed by lane_h:cancel() - -

@@ -996,36 +997,33 @@

Cancelling

-	bool[,reason] = lane_h:cancel( "soft" [, timeout] [, wake_bool])
-	bool[,reason] = lane_h:cancel( "hard" [, timeout] [, force [, forcekill_timeout]])
-	bool[,reason] = lane_h:cancel( [mode, hookcount] [, timeout] [, force [, forcekill_timeout]])
+	bool[,reason] = lane_h:cancel( "soft" [, timeout] [, wake_lane])
+	bool[,reason] = lane_h:cancel( "hard" [, timeout] [, wake_lane])
+	bool[,reason] = lane_h:cancel( [mode, hookcount] [, timeout] [, wake_lane])
 

cancel() sends a cancellation request to the lane.
- First argument is a mode can be one of "hard", "soft", "count", "line", "call", "ret". + First argument is a mode can be one of "hard", "soft", "call", "ret", "line", "count". 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.

If mode is "soft", cancellation will only cause cancel_test() to return true, so that the lane can cleanup manually.
- If wake_bool 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.

If mode is "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).
- timeout defaults to 0 if not specified. + wake_lane defaults to true, and timeout defaults to 0 if not specified.

Other values of mode will asynchronously install the corresponding hook, then behave as "hard".

-

- If force_kill_bool is true, forcekill_timeout can be set to tell how long lanes will wait for the OS thread to terminate before raising an error. Windows threads always terminate immediately, but it might not always be the case with some pthread implementations. -

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.

- If the lane is still running after the timeout expired and force_kill is true, the OS thread running the lane is forcefully killed. This means no GC, probable OS resource leaks (thread stack, locks, DLL notifications), and should generally be the last resort. + If the lane is still running after the timeout expired, there is a chance lanes will raise an error 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. @@ -1396,6 +1394,14 @@ events to a common Linda, but... :). Default duration is null, which should only cause a thread context switch.

+
+	number = lanes.now_secs()
+
+ +

+ Returns the current value of the clock used by timers and lindas. +

+

Locks etc.

@@ -1797,3 +1803,4 @@ int luaD_new_clonable( lua_State* L) + \ No newline at end of file -- cgit v1.2.3-55-g6feb