Skip to content

Instantly share code, notes, and snippets.

@MichaelBlume
Created October 3, 2014 22:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MichaelBlume/06cccde7217e22e77dbb to your computer and use it in GitHub Desktop.
Save MichaelBlume/06cccde7217e22e77dbb to your computer and use it in GitHub Desktop.
(defn swap-out! [a new-val]
(loop []
(let [old-val @a]
(if (compare-and-set! a old-val new-val)
old-val
(recur)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment