code: def compare_and_set(self, oldval, newval):
          '''
          Given `oldval` and `newval`, sets the atom's value to `newval` if and
          only if `oldval` is the atom's current value. Returns `True` upon
          success, otherwise `False`.
  
          :param oldval: The old expected value.
          :param newval: The new value which will be set if and only if `oldval`
              equals the current value.
          '''
          ret = self._state.compare_and_set(oldval, newval)
          if ret:
              self.notify_watches(oldval, newval)
  
          return ref compare_and_set(self, oldval, newval):
          '''
          Given `oldval` and `newval`, sets the atom's value to `newval` if and
          only if `oldval` is the atom's current value. Returns `True` upon
          success, otherwise `False`.
  
          :param oldval: The old expected value.
          :param newval: The new value which will be set if and only if `oldval`
              equals the current value.
          '''
          ret = self._state.compare_and_set(oldval, newval)
          if ret:
              self.notify_watches(oldval, newval)
  
          return ret
docs: Given `oldval` and `newval`, sets the atom's value to `newval` if and
          only if `oldval` is the atom's current value. Returns `True` upon
          success, otherwise `False`.
  
          :param oldval: The old expected value.
          :param newval: The new value which will be set if and only if `oldval`
              equals the current value.