Created
June 24, 2020 06:34
-
-
Save softberries/49b6c79c31b1ce6c21bd33c615adf7d0 to your computer and use it in GitHub Desktop.
This file contains 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
def modify[B](f: A => (A, B)): F[B] = { | |
@tailrec | |
def spin: B = { | |
val c = ar.get | |
val (u, b) = f(c) | |
if (!ar.compareAndSet(c, u)) spin | |
else b | |
} | |
F.delay(spin) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment