All Manuals > LispWorks® User Guide and Reference Manual > 42 The MP Package

mailbox-send-limited Function

Summary

Adds an object to a mailbox if it is not full.

Package

mp

Signature

mailbox-send-limited mailbox object limit &optional timeout wait-reason wait-function &rest args => success

Arguments
mailbox
object
An object.
limit
An integer.
timeout
A non-negative real or nil.
wait-reason
A string or nil.
wait-function, args
A function and its arguments.
Values
success
A boolean.
Description

The function mailbox-send-limited adds object to mailbox in the same way as mailbox-send, except in the case where mailbox is full.

If mailbox is full and has a size less than limit then mailbox is enlarged to have a size that is at most limit and object is added to mailbox.

Otherwise, if mailbox is full and has a size not less than limit then mailbox-send-limited waits until mailbox becomes not full before adding object. While waiting, mailbox-send-limited will return without adding object to mailbox if timeout is non-nil and timeout seconds has elapsed or if wait-function is non-nil and applying wait-function to args returns true.

wait-reason is used as the wait-reason while waiting.

success is true if the object was added to the mailbox and false otherwise (timeout reached or wait-function returned true).

Notes

mailbox-send-limited only prevents the mailbox from expanding to more than limit: if is already bigger than the limit, and there is still a space in it, mailbox-send-limited add the object to the mailbox even if that means that the mailbox has more objects than limit. As long as all of the sending calls on a mailbox are limited, the mailbox may grow until it reaches the largest limit, and if it was made with the :size argument equal or larger than the largest limit, it will never grow. However, if mailbox-send is called then that may enlarge it.

process-send uses mailbox-send, so may expand the mailbox too. It also has a limit argument.

mailbox-send-limited waits like process-wait-with-timeout. As a result, there may be some latency between the time the mailbox becomes non-full and the waiting returns, because it depends on the scheduler. wait-reason, timeout, wait-function and args are analogous to the arguments of process-wait-with-timeout. wait-function is applied within the wait-function that mailbox-send-limited uses, so has the same limitations as the wait-function of process-wait-with-timeout.

When timeout is 0 mailbox-send-limited never waits.

See also

mailbox-send
mailbox-read
process-send
mailbox-count
mailbox-size
mailbox-full-p
19.6.3 Communication between processes and synchronization


LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:51