tofu.interop.AtomByRef.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tofu-core-ce3_2.12 Show documentation
Show all versions of tofu-core-ce3_2.12 Show documentation
Opinionated set of tools for functional programming in Scala
The newest version!
package tofu.interop
import tofu.concurrent.Atom
import cats.effect.Ref
final case class AtomByRef[F[_], A](ref: Ref[F, A]) extends Atom[F, A] {
override def get: F[A] = ref.get
override def set(a: A): F[Unit] = ref.set(a)
override def getAndSet(a: A): F[A] = ref.getAndSet(a)
override def update(f: A => A): F[Unit] = ref.update(f)
override def modify[B](f: A => (A, B)): F[B] = ref.modify(f)
}