Portable_kernel.Atomic_arraymodule Compare_failed_or_set_here = Atomic.Compare_failed_or_set_hereRepresents an array of atomic locations.
This is essentially a 'a Core.Atomic.t array, except it avoids the extra indirection of an atomic ref at each index.
include sig ... endval t_of_sexp : 'a. (Sexplib0.Sexp.t -> 'a) -> Sexplib0.Sexp.t -> 'a tinclude sig ... endval quickcheck_generator :
'a. 'a Ppx_quickcheck_runtime.Base_quickcheck.Generator.t ->
'a t Ppx_quickcheck_runtime.Base_quickcheck.Generator.tval quickcheck_observer :
'a. 'a Ppx_quickcheck_runtime.Base_quickcheck.Observer.t ->
'a t Ppx_quickcheck_runtime.Base_quickcheck.Observer.tval quickcheck_shrinker :
'a. 'a Ppx_quickcheck_runtime.Base_quickcheck.Shrinker.t ->
'a t Ppx_quickcheck_runtime.Base_quickcheck.Shrinker.tcreate ~len value creates a new array of n atomic locations having given value.
init n ~f returns a fresh atomic array of length n, with element number i initialized to the result of f i.
of_list l returns a fresh atomic array containing the elements of the list l.
to_list atomic_array returns a list containing the elements of the atomic array atomic_array. The loads of the elements of the array to populate the list are done atomically.
length atomic_array returns the length of the atomic_array.
get atomic_array index reads and returns the value at the specified index of the atomic_array. Raises Invalid_argument if index is out of bounds.
val set :
'a. 'a t @ local ->
(Base.int ->
('a @ portable contended ->
Base.unit) @ local) @ local @@ portableset atomic_array index value writes the given value to the specified index of the atomic_array. Raises Invalid_argument if index is out of bounds.
val exchange :
'a. 'a t @ local ->
(Base.int ->
('a @ portable contended ->
'a @ portable contended) @ local) @ local @@ portableexchange atomic_array index value sets the value at index to value, and returns the previous value. Raises Invalid_argument if index is out of bounds.
val compare_and_set :
'a. 'a t @ local ->
(Base.int ->
(if_phys_equal_to:'a @ contended ->
(replace_with:'a @ portable contended ->
Compare_failed_or_set_here.t) @ local) @ local) @ local @@ portablecompare_and_set atomic_array index ~if_phys_equal_to ~replace_with atomically updates the specified index of the atomic_array to replace_with only if its current value is physically equal to if_phys_equal_to -- the comparison and the set occur atomically. Returns Set_here if the update was successful, or Compare_failed otherwise. Raises Invalid_argument if index is out of bounds.
val compare_exchange :
'a. 'a t @ local ->
(Base.int ->
(if_phys_equal_to:'a @ contended ->
(replace_with:'a @ portable contended ->
'a @ portable contended) @ local) @ local) @ local @@ portablecompare_exchange atomic_array index ~if_phys_equal_to ~replace_with sets the new value at index to replace_with only if its current value is physically equal to if_phys_equal_to -- the comparison and the set occur atomically. Returns the previous value at index, or the current (unchanged) value if the comparison failed. Raises Invalid_argument if index is out of bounds.
val fetch_and_add :
Base.int t @ local ->
(Base.int ->
(Base.int ->
Base.int) @ local) @ local @@ portablefetch_and_add atomic_array index n atomically increments the value at index by n, and returns the previous value (before the increment). Raises Invalid_argument if index is out of bounds.
add atomic_array index i atomically adds i to the value at index. Raises Invalid_argument if index is out of bounds.
sub atomic_array index i atomically subtracts i from the value at index. Raises Invalid_argument if index is out of bounds.
val logand :
Base.int t @ local ->
(Base.int ->
(Base.int ->
Base.unit) @ local) @ local @@ portablelogand atomic_array index i atomically bitwise-ands i onto the value at index. Raises Invalid_argument if index is out of bounds.
logor atomic_array index i atomically bitwise-ors i onto the value at index. Raises Invalid_argument if index is out of bounds.
val logxor :
Base.int t @ local ->
(Base.int ->
(Base.int ->
Base.unit) @ local) @ local @@ portablelogxor atomic_array index i atomically bitwise-xors i onto the value at index. Raises Invalid_argument if index is out of bounds.
incr atomic_array index atomically increments the value at index by 1. Raises Invalid_argument if index is out of bounds.
decr atomic_array index atomically decrements the value at index by 1. Raises Invalid_argument if index is out of bounds.
Unsafe versions that do not perform bounds checking
val unsafe_compare_and_set :
'a. 'a t @ local ->
(Base.int ->
(if_phys_equal_to:'a @ contended ->
(replace_with:'a @ portable contended ->
Compare_failed_or_set_here.t) @ local) @ local) @ local @@ portable