AtomicRef
An object reference that may be updated atomically.
__init__(initial_value=None)
¶
compare_and_set(expected, desired)
¶
Atomically read the current value of this AtomicRef:
- if it is
expected, then replace it withdesiredand returnTrue - else, don't change it and return
False.
get()
¶
Atomically read the current value of this AtomicRef.
get_and_set(desired)
¶
Atomically swap the value of this AtomicRef to desired and return
the previously stored value.
get_handle()
¶
Get a thread-local handle for this AtomicRef.
When using a thread-local handle, you can improve the performance of your application.
See ThreadHandle for more
information on thread-local object handles.
set(desired)
¶
Unconditionally set the value of this AtomicRef to desired.
Warning
Use compare_and_set
instead.
When using this method, it is not possible to know that the value currently
stored is the one being expected -- it may be mutated by another thread before
this mutation is applied. Use this method only when no other thread may be
writing to this AtomicRef.