Giovanni Gigante wrote:
>
> Which of the following operations are thread-safe, i.e. in which of the
> following (if any) a thread can access a global variable without the
> need for a locking mechanism?
>
> a) aref
> b) aref [1]
> c) setf aref
> d) setf aref [1]
My guess is that all of those are thread-safe.
Don't take my word for it.
> e) gethash
> f) gethash [2]
> g) setf gethash
> h) setf gethash [2]
>From the documentation of MAKE-HASH-TABLE:
:SYNCHRONIZED
If NIL (the default), the hash-table may have multiple concurrent readers,
but results are undefined if a thread writes to the hash-table
concurrently with another reader or writer. If T, all concurrent accesses
are safe, but note that CLHS 3.6 (Traversal Rules and Side Effects)
remains in force. See also: SB-EXT:WITH-LOCKED-HASH-TABLE. This keyword
argument is experimental, and may change incompatibly or be removed in the
future.
> also, svref instead of aref, if that makes any difference.
Probably not.
Leslie
--
http://www.linkedin.com/in/polzer
|