From 074a7157b6bd3867b60d04f685cdede6063e6e3c Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Wed, 7 May 2025 15:43:01 +0200 Subject: Thread priority rework * thread priorities can now be set using the native range of values, if desired. * thread API errors cause a Lua error instead of aborting the program. * new function lanes.thread_priority_range(), to query the valid range of priorities. * unit tests for all of the above --- docs/index.html | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'docs/index.html') diff --git a/docs/index.html b/docs/index.html index e3fbd0b..be8ad7f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -71,7 +71,7 @@

- This document was revised on 23-Apr-25, and applies to version 4.0.0. + This document was revised on 07-May-25, and applies to version 4.0.0.

@@ -106,7 +106,7 @@
  • Threads can be given priorities.
  • Lanes are cancellable, with proper cleanup.
  • No Lua-side application level locking - ever!
  • -
  • Several totally independant Lanes universes may coexist in an application, one per "master" Lua state.
  • +
  • Several totally independent Lanes universes may coexist in an application, one per "master" Lua state.
  • @@ -117,7 +117,7 @@
  • Sharing full userdata between states needs special C side preparations (-> deep userdata and -> clonable userdata).
  • Network level parallelism not included.
  • Multi-CPU is done with OS threads, not processes. A lane is a Lua full userdata, therefore it will exist only as long as the Lua state that created it still exists. Therefore, a lane won't continue execution after the main program's termination.
  • -
  • Just like independant Lua states, Lanes universes cannot communicate together.
  • +
  • Just like independent Lua states, Lanes universes cannot communicate together.
  • @@ -190,6 +190,7 @@
  • lanes.genlock(): obtain an atomic-like data stack
  • lanes.linda(): create a Linda
  • lanes.nameof(): find where a value exists
  • +
  • lanes.thread_priority_range(): obtain the valid range of thread priorities
  • lanes.now_secs(): obtain the current clock value
  • lanes.register(): scan modules so that functions using them can be transferred
  • lanes.set_thread_priority(): change thread priority
  • @@ -863,12 +864,13 @@ - .priority + .priority
    + .native_priority integer - The priority of lanes generated in the range -3..+3 (default is 0). - These values are a mapping over the actual priority range of the underlying implementation.
    + priority: The priority of lanes in the range [-3,+3] (default is 0). These values are a mapping over the actual priority range of the underlying implementation.
    + native_priority: The priority of lanes in a platform-dependent the range. Use lanes.thread_priority_range() to query said range. Implementation and dependability of priorities varies by platform. Especially Linux kernel 2.6 is not supporting priorities in user mode.
    A lane can also change its own thread priority dynamically with lanes.set_thread_priority(). @@ -957,14 +959,17 @@
    -
    	lanes.set_thread_priority(prio)
    +
    	prio_min, prio_max = lanes.thread_priority_range(prio [,"native"])
    +
    	lanes.set_thread_priority(prio [,"native"])

    Besides setting a default priority in the generator settings, each thread can change its own priority at will. This is also true for the main Lua state.
    - The priority must be in the range [-3,+3]. + lanes.thread_priority_range() returns the range of acceptable mapped values. If nothing is specified, should be [-3,3] or [0,3], depending on the threading implementation. +
    + lanes.thread_priority_range('native') returns the range of acceptable native values. The actual values are threading implementation dependent. And some implementations can only accept some values inside that range. YMMV.

    -- cgit v1.2.3-55-g6feb