Actor that delegates message handling to a pluggable behavior. More...
#include <actor.hpp>
Public Member Functions | |
| void | Become (IBehavior *behavior) |
| Switch to a new behavior. | |
| void | Receive (TMessageId messageId, TBlob blob, TActorContext::TPtr ctx) override |
| Delegate message handling to the current behavior. | |
Additional Inherited Members | |
Public Types inherited from NNet::NActors::IActor | |
| using | TPtr = std::unique_ptr< IActor > |
Actor that delegates message handling to a pluggable behavior.
Enables runtime behavior switching — useful for state machines and protocol handlers. Most commonly the actor itself is the initial behavior (Become(this)), but separate TBehavior objects can be stored as members and swapped in.
Usage example:
|
inline |
Switch to a new behavior.
The switch takes effect on the next incoming message. The behavior pointer must remain valid for the lifetime of the actor — storing behaviors as member variables is the typical pattern.
| behavior | Non-owning pointer to the new behavior; must not be null |
|
inlineoverridevirtual |
Delegate message handling to the current behavior.
| messageId | Type identifier of the message |
| blob | Serialized message data |
| ctx | Actor context for communication |
Implements NNet::NActors::IActor.