http://atfykf7jyn4uxuwdqmonyz4xohrw5mrnrldkwtulxkpictxrm3xxfsyd.onion/@tylerneely/fear-and-loathing-in-lock-free-programming-7158b1cdd50c
CAS(variable, old, new) is the shorthand I will use. If variable is set to 0 then CAS(variable, 0, 1) would succeed, as long as another thread didn’t change the value while we weren’t looking. Then CAS(variable, 1, 0) would set it back.