arrow-fx-coroutines / arrow.fx.coroutines / Atomic / invoke

invoke

suspend operator fun <A> invoke(a: A): Atomic<A>

Creates a AtomicRef with a initial value of A.

Data type on top of atomic to use in parallel functions.

import arrow.fx.coroutines.*

suspend fun main() {
  val count = Atomic(0)
  (0 until 20_000).parTraverse {
    count.update(Int::inc)
  }
  println(count.get())
}

Do you like Arrow?

Arrow Org
<