code: def update(self, function):
      
      with self.lock:
        oldValue = self.value
        self.value = function(oldValue)
        return oldValue, self.value
docs: Atomically apply function to the value, and return the old and new values.