Ref. Looking at their interface they both provide methods for
set/put(a: A): F[Unit]. Can't
MVarin place of
Ref? I understand that
MVarcan be used as a communication channel ( blocking on
put) which is not possible with
Deferredare coming from fs2,
MVaris coming from Monix (and of course from Haskell, although in Haskell you also have STM)
MVar, separating the functionality into
Can't MVar in place of Ref?
Anyway if you do
set/put, it will break in the presence of concurrency
Refis also lighter weight
Eqvariant sounds appealing, I could come up with a proposal
Deferredyou can implement structures that aren't
Queuein fs2 are implemented with
Deferred(used to be called
MVarallows you to do both at once
Refas something that could deal with concurrent state only
Deferredis very simple: starts empty, becomes full, can't be emptied or modified again.
geton empty waits (asyncly), get on full immediately returns.
completeon empty unblocks the readers,
completeon full fails
MVargives a lot more ways to end up in deadlock