Created
October 3, 2012 00:38
-
-
Save gakuzzzz/3824224 to your computer and use it in GitHub Desktop.
汎用CASループ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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