module AtomicReferenceArray: sig .. end
Atomic containers for arrays of values.
type 'a t = java'util'concurrent'atomic'AtomicReferenceArray java_instance
The type of atomic containers for arrays values.
WARNING: physical comparison is used by the container.
CONSEQUENCE 1: should be used with caution to store int32,
int64, nativeint, or double values as they are wrapped into
blocks. Hence, comparisons are done on block addresses rather than
on wrapped values.
CONSEQUENCE 2: as OCaml-Java uses boxed values for int values,
the container should not be used to store int values.
Any other type can be safely stored (caching of some int values
ensure that sum types are correctly handled).
type index = int32
The type of array indices.
val make : int32 -> 'a -> 'a t
Returns a new container holding an array of passed length.
Raises Java_error if passed length is negative
val compare_and_set : 'a t -> index -> 'a -> 'a -> bool
compare_and_set a i e u atomically sets the value of a at index
i to u if the current value is e. Returns whether the value of
a at index i was equal to e.
Raises Java_error if passed index is invalid
val get : 'a t -> index -> 'a
Returns the value at passed index.
Raises Java_error if passed index is invalid
val get_and_set : 'a t -> index -> 'a -> 'a
get_and_set a i x atomically sets the value of a at index i to
x, and returns the previous value.
Raises Java_error if passed index is invalid
val lazy_set : 'a t -> index -> 'a -> unit
lazy_set a i x eventually sets the value of a at index i to
x.
Raises Java_error if passed index is invalid
val length : 'a t -> int32
Returns the length of the array.
val set : 'a t -> index -> 'a -> unit
set a i x sets the value of a at index i to x.
Raises Java_error if passed index is invalid
val weak_compare_and_set : 'a t -> index -> 'a -> 'a -> bool
Similar to
AtomicReferenceArray.compare_and_set, with a
weak semantics: may be
faster on some platforms, but does not provide ordering guarantees.
Raises Java_error if passed index is invalid
Null value
val null : 'a t
The null value.
val is_null : 'a t -> bool
is_null obj returns true iff obj is equal to null.
val is_not_null : 'a t -> bool
is_not_null obj returns false iff obj is equal to null.
Miscellaneous
val wrap : 'a t -> 'a t option
wrap obj wraps the reference
obj into an option type:
Some x if obj is not null;
None if obj is null.
val unwrap : 'a t option -> 'a t
unwrap obj unwraps the option
obj into a bare reference:
Some x is mapped to x;
None is mapped to null.