Atomicity from single-cycle compare & swap

There is a wonderful function defined in scala.concurrent.Future┬átrait called onComplete. Here is the declaration: There is one key-point in the documentation which says : If the future has already been completed, this will either be applied immediately or be scheduled asynchronously. The reason I call…