From ae582acdb1bfb3fb4171682b884545d174e95aa9 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Mon, 10 Jun 2024 16:49:58 +0200 Subject: linda:send() returns nil, in case of error --- docs/index.html | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'docs') diff --git a/docs/index.html b/docs/index.html index 24c7c52..5675f65 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1221,7 +1221,7 @@

-	true|lanes.cancel_error = h:limit(key, n_uint)
+	true|(nil,[lanes.cancel_error|"timeout"]) = h:limit(key, n_uint)
 

@@ -1238,42 +1238,49 @@ Timeouts are given in seconds (>= 0, millisecond accuracy) or nil. Timeout can be omitted only if the first key is not a number (then it is equivalent to an infinite duration).
Each key acts as a FIFO queue. There is no limit to the number of keys a Linda may contain. Different Lindas can have identical keys, which are totally unrelated.

+ +

+ Multiple values can be sent to a given key at once, atomically (the send will fail unless all the values fit within the queue limit). This can be useful for multiple producer scenarios, if the protocols used are giving data in streams of multiple units. + Atomicity avoids the producers from garbling each others messages, which could happen if the units were sent individually. +

+

If no data is provided after the key, send() raises an error.
Also, if linda.null or lanes.null is sent as data in a Linda, it will be read as a nil.
- send() returns true if the sending succeeded, and false if the queue limit was met, and the queue did not empty enough during the given timeout.
- send() returns lanes.cancel_error if interrupted by a soft cancel request.
+ send() return values can be: +

 	key, val = h:receive([timeout_secs,] key [, key...])
 
-	key, val [, val...] = h:receive(timeout, h.batched, key, n_uint_min[, n_uint_max])
+	key, val [, val...] = h:receive([timeout,] h.batched, key, n_uint_min[, n_uint_max])
 
- -

- The send() and receive() methods use Linda keys as FIFO stacks (first in, first out).
- In batched mode, linda:receive() will raise an error if min_count < 1 or max_count < min_count. -

-

- Note that any number of lanes can be reading or writing a Linda. There can be many producers, and many consumers. It is up to you. + Unbatched receive() return values can be: +

- Hard cancellation will cause pending Linda operations to abort execution of the lane through a cancellation error. This means that you have to install a finalizer in your lane if you want to run some code in that situation. + In batched mode, linda:receive() will raise an error if min_count < 1 or max_count < min_count.

- Equally, receive() returns a key and the value extracted from it. Note that nils can be sent and received; the key value will tell it apart from a timeout.
- receive() returns nil, lanes.cancel_error if interrupted by a hard cancel request.
- receive() returns nil, "timeout" if nothing was available. + Note that any number of lanes can be reading or writing a Linda. There can be many producers, and many consumers. It is up to you.

- Multiple values can be sent to a given key at once, atomically (the send will fail unless all the values fit within the queue limit). This can be useful for multiple producer scenarios, if the protocols used are giving data in streams of multiple units. - Atomicity avoids the producers from garbling each others messages, which could happen if the units were sent individually. + Remember that Hard cancellation will cause pending Linda operations to abort execution of the lane through a cancellation error. This means that you have to install a finalizer in your lane if you want to run some code in that situation.

-- cgit v1.2.3-55-g6feb