The relevant chapter of the reference is "Concurrency and Parallelism" (
https://docs.racket-lang.org/reference/threads.html):

> All constant-time procedures and operations provided by Racket are
> thread-safe because they are atomic. For example, set!
> <https://docs.racket-lang.org/reference/set_.html#%28form._%28%28quote._~23~25kernel%29._set%21%29%29>
> assigns to a variable as an atomic action with respect to all threads, so
> that no thread can see a “half-assigned” variable. Similarly, vector-set!
> <https://docs.racket-lang.org/reference/vectors.html#%28def._%28%28quote._~23~25kernel%29._vector-set%21%29%29>
> assigns to a vector atomically. The hash-set!
> <https://docs.racket-lang.org/reference/hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-set%21%29%29>
> procedure is not atomic, but the table is protected by a lock; see Hash
> Tables <https://docs.racket-lang.org/reference/hashtables.html> for more
> information.


The way that `box-cas!` is special is that—like a hardware compare-and-set
operation—the compound operation is atomic, so no other thread/future can
interfere between the "compare" step and the "set" step.

-Philip

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAH3z3gavC8HJj2WqFcMeGw06q%3Dd%3DL7ExxxjGBVD1gSc34C%3DgsA%40mail.gmail.com.

Reply via email to