Open jun14 opened 7 years ago
I have this problem too
First, a general note: do not keep references directly to actors, and there is rarely a need to call Actor::ref
. The suggested pattern is ActorRef<...> actor = new Actor<?>(...).spawn()
. If you then need to join the actor, use LocalActor.join(actor)
.
Now to the matter at hand. This is certainly a documentation bug, and possibly an enhancement request. Currently (unlike what the documentation says), Quasar actors do not respect the mailbox's overflow policy, and every overflow will result in an exception being thrown in the actor by receive
. It may be useful to support different policies, but there are strong reasons against it: actors are a programming paradigm designed for one purpose -- the encapsulation of runtime errors. Having a caller block because of an actor's internal behavior seems to defeat this purpose, not to mention that actors may be remote and blocking would then take on a different meaning.
So, regardless of whether we choose to support different policies that may be useful in some circumstances we haven't foreseen, it does not seem like a good idea in general to want an actor's mailbox to block the sender. If you want blocking behavior, you can use regular channels and fibers, which are designed for concurrency more than for fault tolerance.
Big thanks for the reply. I think I'm gonna change my project to use regular channels and fibers instead.
e.g. I set the mailbox size of an actor to 20, and then send 100 messages to this actor. It stops running.
I'm wondering if it is not supported or sugguested to set the mailbox size to Actors