|
|
|
|
|
by signa11
2305 days ago
|
|
> * there could be a scheme where a message is lost if it isn't handled in the current actor's state (or if it isn't deferred explicitly); that's weird :) how can a message be 'lost' from a mailbox without any explicit 'read-message-from-mailbox' call from the actor itself. now, an actor can choose to ignore messages in some states, but then again a suitable protocol needs to exist between the interacting parties on how to proceed. > * there could be a scheme where a message that is not handled in the current state is deferred automatically (for example, Erlang's selective receive). sure, but that was conscious decision on part of the actor. message was not 'lost' per-se > The main problem is: a developer should understand that problem and should implement that in code. But people make mistakes... oh most definitely yes. which is why having callflow diagrams is so ever useful. moreso when dealing with actor like environments... |
|
It depends on the implementation of actors. If an actor is represented as a thread/fiber then an actor is responsible to call `receive` method from time to time. The only example of such an approach I know in the C++ world is Just::Thread Pro library. But even in that case, a message can be ignored if a user writes the wrong if-then chain (or `switch` statement).
But actors often implemented as an object with callbacks those are called by actor framework at the appropriate time. List of callbacks can differ from state to state.