1from typing
import Callable, Generic, TypeVar
8 This has the same API as Java's AtomicReference, but it doesn't make any sense in the Python runtime.
9 The point of keeping it is that it makes the port from Kotlin more 1:1
13 self.
value: T = initial_value
18 def set(self, new_value: T) ->
None:
22 old_value = self.
value
23 self.
value = new_value
27 if self.
value == expected_value:
28 self.
value = new_value
33 old_value = self.
value
42 old_value = self.
value
T get_and_update(self, Callable[[T], T] update_function)
bool compare_and_set(self, T expected_value, T new_value)
T get_and_accumulate(self, T x, Callable[[T, T], T] accumulator)
T get_and_set(self, T new_value)
__init__(self, T initial_value)
T update_and_get(self, Callable[[T], T] update_function)
None set(self, T new_value)
T accumulate_and_get(self, T x, Callable[[T, T], T] accumulator)