Welcome! Got a question? Do you have -Ypartial-unification turned on? Other FAQs: http://typelevel.org/cats/faq.html
MVar
allows you to do both at once
Ref
as something that could deal with concurrent state only
Deferred
is very simple: starts empty, becomes full, can't be emptied or modified again. get
on empty waits (asyncly), get on full immediately returns. complete
on empty unblocks the readers, complete
on full fails
MVar
gives a lot more ways to end up in deadlock
MVar
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
I imagine if all worker
s and client
s share the same mvar
instance we get something that looks like a queue