Skip to content

Instantly share code, notes, and snippets.

@gakuzzzz
Created October 3, 2012 00:38
Show Gist options
  • Save gakuzzzz/3824224 to your computer and use it in GitHub Desktop.
Save gakuzzzz/3824224 to your computer and use it in GitHub Desktop.
汎用CASループ
implicit def cas[A](reference: AtomicReference[A]) = new {
def compareAndSet(f: A => A): Unit = {
val current = reference.get
if (reference.compareAndSet(current, f(current))) ()
else compareAndSet(f)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment