An AtomicStampedReference maintains an object reference along with an integer "stamp", that can be updated atomically.
Implementation note: This implementation maintains stamped references by creating internal objects representing "boxed" [reference, integer] pairs.
An AtomicStampedReference maintains an object reference along with an integer "stamp", that can be updated atomically. Implementation note: This implementation maintains stamped references by creating internal objects representing "boxed" [reference, integer] pairs.
(->atomic-stamped-reference initial-ref initial-stamp)
Constructor.
Creates a new AtomicStampedReference with the given initial values.
initial-ref - the initial reference - V
initial-stamp - the initial stamp - int
Constructor. Creates a new AtomicStampedReference with the given initial values. initial-ref - the initial reference - `V` initial-stamp - the initial stamp - `int`
(attempt-stamp this expected-reference new-stamp)
Atomically sets the value of the stamp to the given update value if the current reference is == to the expected reference. Any given invocation of this operation may fail (return false) spuriously, but repeated invocation when the current value holds the expected value and no other thread is also attempting to set the value will eventually succeed.
expected-reference - the expected value of the reference - V
new-stamp - the new value for the stamp - int
returns: true if successful - boolean
Atomically sets the value of the stamp to the given update value if the current reference is == to the expected reference. Any given invocation of this operation may fail (return false) spuriously, but repeated invocation when the current value holds the expected value and no other thread is also attempting to set the value will eventually succeed. expected-reference - the expected value of the reference - `V` new-stamp - the new value for the stamp - `int` returns: true if successful - `boolean`
(compare-and-set this expected-reference new-reference expected-stamp new-stamp)
Atomically sets the value of both the reference and stamp to the given update values if the current reference is == to the expected reference and the current stamp is equal to the expected stamp.
expected-reference - the expected value of the reference - V
new-reference - the new value for the reference - V
expected-stamp - the expected value of the stamp - int
new-stamp - the new value for the stamp - int
returns: true if successful - boolean
Atomically sets the value of both the reference and stamp to the given update values if the current reference is == to the expected reference and the current stamp is equal to the expected stamp. expected-reference - the expected value of the reference - `V` new-reference - the new value for the reference - `V` expected-stamp - the expected value of the stamp - `int` new-stamp - the new value for the stamp - `int` returns: true if successful - `boolean`
(get this stamp-holder)
Returns the current values of both the reference and the stamp. Typical usage is int[1] holder; ref = v.get(holder); .
stamp-holder - an array of size of at least one. On return, stampholder[0] will hold the value of the stamp. - int[]
returns: the current value of the reference - V
Returns the current values of both the reference and the stamp. Typical usage is int[1] holder; ref = v.get(holder); . stamp-holder - an array of size of at least one. On return, stampholder[0] will hold the value of the stamp. - `int[]` returns: the current value of the reference - `V`
(get-reference this)
Returns the current value of the reference.
returns: the current value of the reference - V
Returns the current value of the reference. returns: the current value of the reference - `V`
(get-stamp this)
Returns the current value of the stamp.
returns: the current value of the stamp - int
Returns the current value of the stamp. returns: the current value of the stamp - `int`
(set this new-reference new-stamp)
Unconditionally sets the value of both the reference and stamp.
new-reference - the new value for the reference - V
new-stamp - the new value for the stamp - int
Unconditionally sets the value of both the reference and stamp. new-reference - the new value for the reference - `V` new-stamp - the new value for the stamp - `int`
(weak-compare-and-set this
expected-reference
new-reference
expected-stamp
new-stamp)
Atomically sets the value of both the reference and stamp to the given update values if the current reference is == to the expected reference and the current stamp is equal to the expected stamp.
May fail spuriously and does not provide ordering guarantees, so is only rarely an appropriate alternative to compareAndSet.
expected-reference - the expected value of the reference - V
new-reference - the new value for the reference - V
expected-stamp - the expected value of the stamp - int
new-stamp - the new value for the stamp - int
returns: true if successful - boolean
Atomically sets the value of both the reference and stamp to the given update values if the current reference is == to the expected reference and the current stamp is equal to the expected stamp. May fail spuriously and does not provide ordering guarantees, so is only rarely an appropriate alternative to compareAndSet. expected-reference - the expected value of the reference - `V` new-reference - the new value for the reference - `V` expected-stamp - the expected value of the stamp - `int` new-stamp - the new value for the stamp - `int` returns: true if successful - `boolean`
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close