mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
a753b0df3e
1 changed files with 18 additions and 5 deletions
|
|
@ -12,24 +12,37 @@ type 'a t = {mutable x: 'a}
|
||||||
let[@inline] make x = {x}
|
let[@inline] make x = {x}
|
||||||
let[@inline] get {x} = x
|
let[@inline] get {x} = x
|
||||||
let[@inline] set r x = r.x <- x
|
let[@inline] set r x = r.x <- x
|
||||||
let[@inline] exchange r x =
|
let[@inline never] exchange r x =
|
||||||
|
(* atomic *)
|
||||||
let y = r.x in
|
let y = r.x in
|
||||||
r.x <- x;
|
r.x <- x;
|
||||||
|
(* atomic *)
|
||||||
y
|
y
|
||||||
|
|
||||||
let[@inline] compare_and_set r seen v =
|
let[@inline never] compare_and_set r seen v =
|
||||||
|
(* atomic *)
|
||||||
if r.x == seen then (
|
if r.x == seen then (
|
||||||
r.x <- v;
|
r.x <- v;
|
||||||
|
(* atomic *)
|
||||||
true
|
true
|
||||||
) else false
|
) else false
|
||||||
|
|
||||||
let[@inline] fetch_and_add r x =
|
let[@inline never] fetch_and_add r x =
|
||||||
|
(* atomic *)
|
||||||
let v = r.x in
|
let v = r.x in
|
||||||
r.x <- x + r.x;
|
r.x <- x + r.x;
|
||||||
|
(* atomic *)
|
||||||
v
|
v
|
||||||
|
|
||||||
let[@inline] incr r = r.x <- 1 + r.x
|
let[@inline never] incr r =
|
||||||
let[@inline] decr r = r.x <- r.x - 1
|
(* atomic *)
|
||||||
|
r.x <- 1 + r.x
|
||||||
|
(* atomic *)
|
||||||
|
|
||||||
|
let[@inline never] decr r =
|
||||||
|
(* atomic *)
|
||||||
|
r.x <- r.x - 1
|
||||||
|
(* atomic *)
|
||||||
|
|
||||||
[@@@endif]
|
[@@@endif]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue