Skip to content

Instantly share code, notes, and snippets.


Created Jul 20, 2017
What would you like to do?
the description for this gist
class LockFreeRook extends Rook {
private var coordinates = new AtomicReference[(Long, Long)]((0,0))
final def updatePosition(offset: (Long, Long)): Unit = {
val prev = coordinates.get()
val updated = (prev._1 + offset._1, prev._2 + offset._2)
if (!coordinates.compareAndSet(prev, updated)) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.