def compare_and_set(self, expected, updated):
return self._encode_invoke(atomic_reference_compare_and_set_codec,<EOL>expected=self._to_data(expected), updated=self._to_data(updated))<EOL>
Atomically sets the value to the given updated value only if the current value == the expected value.

:param expected: (object), the expected value.
:param updated: (object), the new value.
:return: (bool), ``true`` if successful; or ``false`` if the actual value was not equal to the expected value.