Atomic.Loc(3)
π Atomic.Loc(3) β like, the atomic locations page, bestie
Okay so this is Atomic.Loc(3) from the OCaml library manual β the Atomic "locations" one, aka record fields that are lowkey built different. Come sit with me, this one's a quick read and honestly kind of a serve. β¨
πΈ NAME πΈ
Atomic.Loc β atomic "locations", such as record fields. That's it, that's the whole vibe check. π
π¦ Module π¦
Module Atomic.Loc
π Documentation π
Module Loc : sig end
Atomic "locations", such as record fields.
Since 5.4 β yeah she's new-new, we love a fresh drop. π
type 'a t = 'a atomic_loc
So here's the tea, bestie: this module exposes a dedicated type 'a Atomic.Loc.t for atomic locations. What's that mean? It means you can have a value of type 'a sitting in an atomic spot inside objects that may not be atomic references β like, the container itself doesn't have to be an atomic ref for the field to be atomic. Main character energy fr fr. π
It's used in particular for atomic record fields: if a record r has an atomic field f of type foo, then
[%atomic.loc r.f]
has type foo Atomic.Loc.t. Not me explaining this with an example and everything π β but like, that's literally the whole point.
The API below mirrors the API to access Atomic.Loc.t β see the documentation above for more information. (Go look up, bestie, that's where the details live π«Ά)
val get : 'a t -> 'a
val set : 'a t -> 'a -> unit
val exchange : 'a t -> 'a -> 'a
val compare_and_set : 'a t -> 'a -> 'a -> bool
val fetch_and_add : int t -> int -> int
val incr : int t -> unit
val decr : int t -> unit
Bestie reminder: every signature above is exactly what's in the manual β don't go renaming types on me, the compiler will literally end you. π
π And that's the whole page, no cap. Signing off for OCamldoc, dated 2026-06-22 β Atomic.Loc(3), slayed, periodt. ππ§ββοΈ
π¦ where this page comes from
- arch rolling: ocaml 5.5.0-1 Β· LGPL2.1 AND custom: QPL-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms