blob: 91e3ba2b8dacbd8283ee0772037fb3e61f9e8eb6 [file] [log] [blame]
import java.util.concurrent.atomic.AtomicReference
static <S> S apply (AtomicReference<S> self, mutation) {
for (;;) {
def s = self.get()
def newState = mutation(s)
if (self.compareAndSet(s, newState))
return newState
print 'foo'
}
}