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
I imagine if all
worker#1 -> mvar.put(1) worker#2 -> mvar.put(2) … worker#n -> mvar.put(n) // they all block asyncly if mvar is non-empty // clients reading forever client#1 -> mvar.take client#2 -> mvar.take … client#n -> mvar.take
clients share the same
mvarinstance we get something that looks like a queue