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