All Manuals > LispWorks® User Guide and Reference Manual > 37 The HCL Package

with-hash-table-locked Macro

Summary

Evaluates code with a hash-table locked against modification by other threads.

Package

hcl

Signature

with-hash-table-locked hash-table &body body => results

Arguments
hash-table
A hash table.
body
Lisp forms.
Values
results
The results of evaluating body.
Description

The macro with-hash-table-locked evaluates body with the hash table hash-table locked against modification by other threads. The current thread can modify hash-table. The lock is exclusive, so if more than one thread tries to lock the same table, one thread will hold the lock and the others will wait until that thread leaves the body of with-hash-table-locked.

with-hash-table-locked is useful not only for multiple accesses to the same table, but also when an access to the table must be consistent with some other operation, avoiding the need to make a separate lock.

See also

gethash-ensuring
make-hash-table
modify-hash
with-ensuring-gethash
19.3 Atomicity and thread-safety of the LispWorks implementation


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