From 598b1739f0477dfc230de7fc350e675b03954218 Mon Sep 17 00:00:00 2001 From: Automatic website updater <> Date: Wed, 18 Mar 2026 09:43:30 +0000 Subject: [PATCH] Automatic website update --- index.html | 392 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 362 insertions(+), 30 deletions(-) diff --git a/index.html b/index.html index 6acb0dd..a99808e 100644 --- a/index.html +++ b/index.html @@ -180,7 +180,11 @@ Next:
-

Undocumented procedure. +

Run THUNK with Guile’s default blocking I/O waiters active. +

+

This is useful when restoring the default Guile I/O waiters from within +a context (like Fibers) where different I/O waiters are used, for +example when creating a new thread from a fiber.

@@ -189,8 +193,19 @@ Next:
-

Undocumented procedure. +

Run THUNK with a SIGINT handler that signals the Fibers condition CVAR. +Restores the previous handler when THUNK returns.

+

Typical usage is to pass a condition variable to this procedure and wait +on CVAR in a fiber to implement clean shutdown on Ctrl-C: +

+
+
(let ((quit-cvar (make-condition)))
+  (call-with-sigint
+    (lambda () (wait quit-cvar))
+    quit-cvar))
+
+
@@ -198,7 +213,11 @@ Next:
-

Undocumented procedure. +

Write OBJ to PORT (default: current output port) as a UTF-8 byte +sequence via put-bytevector. +

+

When used with ports without buffering, this should be safer than +display.

@@ -207,7 +226,8 @@ Next:
-

Undocumented procedure. +

Like format but should be safer when used with a port without +buffering.

@@ -252,7 +272,8 @@ Next:
-

Undocumented procedure. +

Like simple-format but should be safer when used with a port +without buffering.

@@ -261,7 +282,10 @@ Next:
-

Undocumented procedure. +

Spawn a fiber to run THUNK, with knots exception handling. +

+

Accepts the same optional SCHEDULER and #:parallel? arguments as +spawn-fiber.

@@ -270,7 +294,11 @@ Next:
-

Undocumented procedure. +

Block until the system clock reads at least 2001-01-02. +

+

Useful at startup in environments (virtual machines, embedded systems) +where the clock may start at or near the Unix epoch. Prints a warning +to the current error port every 20 seconds while waiting.

@@ -320,7 +348,16 @@ Next:
-

Undocumented procedure. +

Open a socket for URI and return it as a non-blocking port. +

+

For HTTPS URIs the TLS handshake is completed while the socket is still +blocking (required because Guile’s TLS wrapper does not support +non-blocking handshakes), then the underlying socket is made +non-blocking. For plain HTTP the socket is made non-blocking +immediately. +

+

#:verify-certificate? controls TLS certificate verification and +defaults to #t.

@@ -405,7 +442,9 @@ this will be raised after all exceptions have finished.
Procedure: call-with-parallelism-limiter a b
-

Undocumented procedure. +

Acquire a slot from PARALLELISM-LIMITER, call THUNK, release the slot, +and return the values from THUNK. Blocks if no slot is currently +available.

@@ -423,7 +462,15 @@ this will be raised after all exceptions have finished.
Procedure: fiberize _ KEY: #:parallelism #:input-channel #:process-channel
-

Undocumented procedure. +

Convert PROC into a procedure backed by #:parallelism (default: +1) background fibers. Returns a wrapper that sends its arguments to one +of the fibers and blocks until the result is returned. +

+

#:input-channel is the channel that callers write requests to; +defaults to a fresh channel. #:process-channel is the channel +the fibers read from; defaults to #:input-channel. Setting them +differently allows external parties to bypass the wrapper and write +directly to process-channel.

@@ -483,7 +530,12 @@ LISTS, or #f if no result has been received yet.
Procedure: make-parallelism-limiter _ KEY: #:name
-

Undocumented procedure. +

Return a parallelism limiter that allows at most LIMIT concurrent fibers +to execute within with-parallelism-limiter at the same time. +Further fibers block until a slot becomes free. +

+

#:name is a string used in log messages. Defaults to +"unnamed".

@@ -531,7 +583,9 @@ Next: , Pre
Procedure: fibers-delay a
-

Undocumented procedure. +

Return a new fiber-aware promise that will evaluate THUNK when first +forced. THUNK is not called until fibers-force is called on the +promise.

@@ -540,7 +594,9 @@ Next: , Pre
Procedure: fibers-delay/eager a
-

Undocumented procedure. +

Return a new fiber-aware promise and immediately begin evaluating THUNK +in a new fiber. Exceptions during eager evaluation are silently +discarded; they will be re-raised when fibers-force is called.

@@ -549,7 +605,12 @@ Next: , Pre
Procedure: fibers-force a
-

Undocumented procedure. +

Force the fiber-aware promise FP, returning its values. +

+

The first call evaluates the promise’s thunk. Concurrent callers block +on a condition variable until evaluation finishes, then receive the same +result. If the thunk raises an exception, the exception is stored and +re-raised for all callers.

@@ -558,7 +619,8 @@ Next: , Pre
Procedure: fibers-promise-reset a
-

Undocumented procedure. +

Reset the fiber-aware promise FP so that the next call to +fibers-force re-evaluates its thunk.

@@ -567,7 +629,9 @@ Next: , Pre
Procedure: fibers-promise-result-available? a
-

Undocumented procedure. +

Return #t if the fiber-aware promise FP has been evaluated +(successfully or with an exception) and #f if evaluation has not +yet started or is still in progress.

@@ -599,7 +663,12 @@ Next:
-

Undocumented procedure. +

Spawn a fiber that serialises items onto DEST-CHANNEL in FIFO order. +Returns a new input channel. +

+

Multiple producers can put items on the returned channel concurrently. +The fiber buffers them locally and forwards them to DEST-CHANNEL one at +a time, preserving arrival order.

@@ -712,7 +781,10 @@ available. Return the resource once PROC has returned.
Procedure: destroy-resource-pool a
-

Undocumented procedure. +

Destroy POOL, preventing any new checkouts. Blocks until all +checked-out resources have been returned, running the pool’s +#:destructor on each. Any fibers waiting for a resource receive +&resource-pool-destroyed.

@@ -721,8 +793,38 @@ available. Return the resource once PROC has returned.
Procedure: make-fixed-size-resource-pool _ KEY: #:delay-logger #:duration-logger #:scheduler #:name #:default-checkout-timeout #:default-max-waiters
-

Undocumented procedure. +

Create a resource pool from RESOURCES-LIST-OR-VECTOR, a list or vector +of pre-existing resource values.

+

Use with-resource-from-pool or +call-with-resource-from-pool to borrow a resource and return it +automatically when done. +

+

Optional keyword arguments: +

+
+
#:name
+

A optional string used in log messages. Defaults to "unnamed". +

+
+
#:default-checkout-timeout
+

Default checkout timeout when requesting a resource from the pool, unset +by default. +

+
+
#:default-max-waiters
+

Maximum number of fibers that may queue waiting for a resource. When +this limit is exceeded, &resource-pool-too-many-waiters is raised +when a resource is requested. Defaults to #f (no limit). +

+
+
#:scheduler
+

The Fibers scheduler to use for the pool’s internal fiber. Defaults to +the current scheduler. +

+
+
+
@@ -730,8 +832,69 @@ available. Return the resource once PROC has returned.
Procedure: make-resource-pool _ _ KEY: #:min-size #:idle-seconds #:delay-logger #:duration-logger #:destructor #:lifetime #:scheduler #:name #:add-resources-parallelism #:default-checkout-timeout #:default-max-waiters
-

Undocumented procedure. +

Create a dynamic resource pool. RETURN-NEW-RESOURCE is a thunk called +to create each new resource value. MAX-SIZE is the maximum number of +resources the pool will hold simultaneously.

+

Resources are created on demand when a checkout is requested and the +pool is not yet at MAX-SIZE. Use with-resource-from-pool or +call-with-resource-from-pool to request a resource and return it +automatically when done. +

+

Optional keyword arguments: +

+
+
#:min-size
+

Minimum number of resources to keep alive even when idle. Defaults to +0. +

+
+
#:idle-seconds
+

Seconds a resource may remain unused before being destroyed, provided +the pool is above #:min-size. Defaults to #f (never +expire idle resources). +

+
+
#:lifetime
+

Maximum number of checkouts a single resource will serve before being +destroyed and replaced by a fresh one. Defaults to #f (no +limit). +

+
+
#:destructor
+

A procedure called as (destructor resource) when a resource is +removed from the pool. Defaults to #f. +

+
+
#:add-resources-parallelism
+

Maximum number of concurrent calls to RETURN-NEW-RESOURCE when the pool +needs to grow. Allowing resources to be created in parallel can result +in more resources being created than can fit inside the pool, if this +happens, the surplus resources are destroyed. Defaults to 1. +

+
+
#:name
+

A string used in log messages. Defaults to "unnamed". +

+
+
#:default-checkout-timeout
+

Default checkout timeout when requesting a resource from the pool, unset +by default. +

+
+
#:default-max-waiters
+

Maximum number of fibers that may queue waiting for a resource. When +this limit is exceeded, &resource-pool-too-many-waiters is raised +when a resource is requested. Defaults to #f (no limit). +

+
+
#:scheduler
+

The Fibers scheduler to use for the pool’s internal fiber. Defaults to +the current scheduler. +

+
+
+
@@ -775,7 +938,31 @@ available. Return the resource once PROC has returned.
Procedure: resource-pool-stats _ KEY: #:timeout
-

Undocumented procedure. +

Return an alist of statistics for POOL with the following keys: +

+
+
resources
+

Total number of resources currently held by the pool. +

+
+
available
+

Number of resources not currently checked out. +

+
+
waiters
+

Number of fibers currently queued waiting for a resource. +

+
+
checkout-failure-count
+

Cumulative number of checkouts where an exception was raised inside the +proc. +

+
+
+ +

Blocks waiting for the pool fiber to respond. #:timeout is the +number of seconds to wait; defaults to 5. Raises +&resource-pool-timeout if the pool does not respond in time.

@@ -906,7 +1093,15 @@ Next:
-

Undocumented procedure. +

Sort ITEMS destructively using LESS as the comparison procedure, using a +parallel merge sort. Returns the sorted list. +

+

Splits ITEMS into chunks, sorts each in an eager fiber-promise in +parallel, then merges pairs of sorted chunks in parallel until one +sorted list remains. +

+

#:parallelism sets the number of initial chunks. Defaults to the +current fibers parallelism.

@@ -991,9 +1186,41 @@ Next: ,
Procedure: call-with-thread _ _ KEY: #:duration-logger #:checkout-timeout #:channel #:destroy-thread-on-exception? #:max-waiters
-

Send PROC to the thread pool through CHANNEL. Return the result of -PROC. If already in the thread pool, call PROC immediately. +

Run PROC in THREAD-POOL and return its values, blocking until complete. +If called from within a thread that already belongs to THREAD-POOL, PROC +is called directly in that thread.

+

Optional keyword arguments: +

+
+
#:checkout-timeout
+

Seconds to wait for a free thread before raising +&thread-pool-timeout-error. Defaults to the pool’s +#:default-checkout-timeout. +

+
+
#:max-waiters
+

Maximum number of fibers that may queue waiting for a thread (for +dynamic pools). Defaults to the pool’s #:default-max-waiters. +

+
+
#:destroy-thread-on-exception?
+

When #t, destroy the thread after PROC raises an exception. +Equivalent to per-call #:expire-on-exception?. Defaults to +#f. +

+
+
#:duration-logger
+

Called as (duration-logger seconds) after PROC completes (whether +or not it raised an exception). +

+
+
#:channel
+

Override the channel used to communicate with the thread. +

+
+
+
@@ -1001,7 +1228,8 @@ PROC. If already in the thread pool, call PROC immediately.
Procedure: destroy-thread-pool a
-

Undocumented procedure. +

Destroy POOL, stopping all of its threads and calling the destructor if +specified. This procedure will block until the destruction is complete.

@@ -1010,8 +1238,63 @@ PROC. If already in the thread pool, call PROC immediately.
Procedure: make-fixed-size-thread-pool _ KEY: #:thread-initializer #:thread-destructor #:delay-logger #:duration-logger #:thread-lifetime #:expire-on-exception? #:name #:use-default-io-waiters? #:default-checkout-timeout
-

Undocumented procedure. +

Create a pool of SIZE threads started immediately. Use +call-with-thread to run a procedure in one of the threads.

+

Optional keyword arguments: +

+
+
#:thread-initializer
+

A thunk called once when each thread starts. Its return value is passed +as extra arguments to every procedure run in that thread. Defaults to +#f (no extra arguments). +

+
+
#:thread-destructor
+

A procedure called with the value returned by +#:thread-initializer when a thread exits. Defaults to #f. +

+
+
#:thread-lifetime
+

Maximum number of procedures a thread will run before restarting (and +re-running #:thread-initializer). Defaults to #f (no +limit). +

+
+
#:expire-on-exception?
+

When #t, replace a thread after any unhandled exception. Defaults +to #f. +

+
+
#:use-default-io-waiters?
+

When #t (the default), each thread uses blocking I/O waiters so +that port reads and writes block the thread rather than trying to +suspend a fiber. +

+
+
#:name
+

String used in thread names and log messages. Defaults to +"unnamed". +

+
+
#:default-checkout-timeout
+

Seconds to wait for a free thread slot before raising +&thread-pool-timeout-error. Defaults to #f (wait +forever). +

+
+
#:delay-logger
+

Called as (delay-logger seconds proc) with the time spent waiting +for a thread to become available. +

+
+
#:duration-logger
+

Called as (duration-logger seconds proc) after each procedure +completes. +

+
+
+
@@ -1019,9 +1302,39 @@ PROC. If already in the thread pool, call PROC immediately.
Procedure: make-thread-pool _ KEY: #:min-size #:scheduler #:thread-initializer #:thread-destructor #:delay-logger #:duration-logger #:thread-lifetime #:expire-on-exception? #:name #:use-default-io-waiters? #:default-checkout-timeout #:default-max-waiters
-

Return a channel used to offload work to a dedicated thread. ARGS are -the arguments of the thread pool procedure. +

Create a dynamic thread pool with up to MAX-SIZE threads. Use +call-with-thread to run a procedure in one of the threads.

+

Unlike make-fixed-size-thread-pool, threads are created on demand +and may be reclaimed when idle (controlled by #:min-size and the +resource pool’s idle management). +

+

Accepts the same #:thread-initializer, +#:thread-destructor, #:thread-lifetime, +#:expire-on-exception?, #:use-default-io-waiters?, +#:name, #:default-checkout-timeout, #:delay-logger, +and #:duration-logger arguments as +make-fixed-size-thread-pool, plus: +

+
+
#:min-size
+

Minimum number of threads to keep alive. Defaults to MAX-SIZE (i.e.: +the pool is pre-filled and never shrinks). +

+
+
#:scheduler
+

Fibers scheduler for the pool’s internal resource pool fiber. Defaults +to the current scheduler. +

+
+
#:default-max-waiters
+

Maximum number of fibers that may queue waiting for a thread. Raises +&thread-pool-timeout-error when exceeded. Defaults to #f +(no limit). +

+
+
+
@@ -1171,7 +1484,12 @@ Next:
-

Undocumented procedure. +

Run THUNK in a new fiber and return its values, waiting TIMEOUT seconds +for it to finish. If THUNK does not complete within TIMEOUT seconds, +the ON-TIMEOUT procedure is called and with-fibers-timeout returns the +result of ON-TIMEOUT instead. +

+

If THUNK raises an exception it is re-raised in the calling fiber.

@@ -1180,7 +1498,21 @@ Next:
-

Undocumented procedure. +

Run THUNK with per-operation I/O timeouts on all ports. If any read or +write blocks for longer than the given number of seconds, an exception +is raised. +

+

#:timeout sets both read and write timeouts. +#:read-timeout and #:write-timeout specify the timeout for +reads and writes respectively. All three default to #f (no +timeout). +

+

This procedure works both with fibers, and without fibers by using the +poll system call with a timeout. +

+

On read timeout, raises &port-read-timeout-error. On write +timeout, raises &port-write-timeout-error. Both carry the +thunk and port fields from &port-timeout-error.