Base interface for all actors in the system. More...
#include <actor.hpp>
Public Types | |
| using | TPtr = std::unique_ptr<IActor> |
Public Member Functions | |
| virtual void | Receive (TMessageId messageId, TBlob blob, TActorContext::TPtr ctx)=0 |
| Process an incoming message. | |
| virtual void | AfterRegister (TActorContext::TPtr) |
| Called once right after the actor is registered in the system. | |
| virtual void | BeforeUnregister (TActorContext::TPtr) |
| Called once on PoisonPill, right before the actor is destroyed. | |
Friends | |
| class | TActorSystem |
Base interface for all actors in the system.
IActor defines the basic contract that all actors must implement. Actors receive messages through the Receive method and can respond by sending messages back through the provided context.
This is the synchronous version of actor interface - the Receive method should complete quickly and not block on I/O operations.
|
inlinevirtual |
Called once right after the actor is registered in the system.
| ctx | Context whose recipient is the actor itself; safe to Send/Schedule from here |
Default implementation does nothing.
|
inlinevirtual |
Called once on PoisonPill, right before the actor is destroyed.
| ctx | Context whose recipient is the actor itself |
Not called when the whole TActorSystem is destroyed. Default does nothing.
|
pure virtual |
Process an incoming message.
| messageId | Type identifier of the message |
| blob | Serialized message data |
| ctx | Actor context for sending responses and accessing actor system |
This method should process the message quickly and not perform blocking operations. For async operations, use ICoroActor instead.
Implemented in NNet::NActors::IBehaviorActor, NNet::NActors::ICoroActor, and NNet::NActors::TAsk< T >.