[ Recorded Database | Reference Manual | Alphabetic Index ]

record_wait_remove(+Key, ?Value, +Timeout)

Variant of erase/2, suitable for thread communication
Key
A record name (atom/compound) or handle.
Value
An arbitrary term.
Timeout
Timeout in seconds (integer or float), or the atom 'block'

Description

Like erase/2, this predicate finds the first term (recorded under Key) that unifies with Value, and removes it from the record. If Value is a variable, it simply removes (and retrieves) the first recorded term.

In addition, this predicate, together with record_wait_append/4, implements a bounded queue with synchronisation between concurrent threads.

If there are no unifiable recorded terms for Key, the predicate blocks until an invocation of record_wait_append/4 (in another thread) records another term, and then attempts the removal again. If no new term is added within Timeout seconds, the predicate fails.

Conversely, when the removal of an element sufficiently reduces the queue length, this predicate unblocks all currently blocking invocations of record_wait_append/4 on the same Key.

Modes and Determinism

Modules

This predicate is sensitive to its module context (tool predicate, see @/2).

Fail Conditions

Fails if there are no records until Timeout expires

Exceptions

(4) instantiation fault
Key or Timeout is not instantiated.
(5) type error
Key is neither atom, compound term, nor record handle.
(5) type error
Timeout is neither integer, float, nor the atom 'block'
(6) out of range
Timeout is a negative number
(45) named object does not exist
Key does is not a declared record name

Examples

see record_wait_append/4

See Also

record_create / 1, recordz / 2, record_wait_append / 4