I'm not sure if setting the attribute on the ivar is a good way to go. Entries in structs, arrays, hashes, etc may also benefit from atomic operations (or at least I would like that). Maybe something like: old = hash["foo"] x= new # swap hash["foo"] ?x= old : new # cas