A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.lispworks.com/documentation/lw71/LW/html/lw-631.htm below:

modify-hash

Description

The function modify-hash locks the hash table hash-table. It then calls the function function with three arguments: key, the value currently associated with key in hash-table (if any), and a flag which is true if the key was in the table. (This last argument is needed in case the associated value is nil).

modify-hash then sets the result of the function function as the value for key in the table. modify-hash returns two values, the new-value and the key.

The overall effect is like:

(with-hash-table-locked
 hash-table
 (multiple-value-bind (value found-p)
     (gethash key
 hash-table
)
   (let ((new-value (funcall function
                             key
 value found-p)))
     (setf (gethash key
 hash-table
) new-value)
     (values new-value key
))))

but modify-hash should be more efficient.

It is guaranteed that no other thread can modify the value associated with key until modify-hash returns.

Notes

function is called with hash-table locked, so it should not do anything that may require hanging the modification, or that waits for another process that tries to modify the table.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4