Context object providing actor communication and scheduling capabilities. More...
#include <actor.hpp>
Classes | |
struct | TAsync |
Helper class for managing asynchronous operations in actors. More... | |
Public Types | |
using | TPtr = std::unique_ptr< TActorContext > |
Public Member Functions | |
TActorId | Sender () const |
Get the sender of the current message. | |
TActorId | Self () const |
Get this actor's ID. | |
void | Send (TActorId to, TMessageId messageId, TBlob blob) |
Send a message to another actor. | |
void | Forward (TActorId to, TMessageId messageId, TBlob blob) |
Forward a message to another actor (preserves original sender) | |
template<typename T , typename... Args> | |
void | Send (TActorId to, Args &&... args) |
Send a typed message to another actor. | |
template<typename T , typename... Args> | |
void | Forward (TActorId to, Args &&... args) |
Forward a typed message to another actor. | |
TEvent | Schedule (TTime when, TActorId sender, TActorId recipient, TMessageId messageId, TBlob blob) |
Schedule a message to be delivered at a specific time. | |
template<typename T , typename... Args> | |
TEvent | Schedule (TTime when, TActorId sender, TActorId recipient, Args &&... args) |
Schedule a typed message to be delivered at a specific time. | |
void | Cancel (TEvent event) |
Cancel a previously scheduled message. | |
TFuture< void > | Sleep (TTime until) |
Sleep until a specific time. | |
template<typename Rep , typename Period > | |
TFuture< void > | Sleep (std::chrono::duration< Rep, Period > duration) |
Sleep for a specific duration. | |
template<typename T , typename TQuestion > | |
TFuture< T > | Ask (TActorId recipient, TQuestion &&question) |
Send a message and wait for a response. | |
TAsync | StartAsync () |
Start an asynchronous operation context. | |
Static Public Member Functions | |
static void * | operator new (size_t size, TActorSystem *actorSystem) |
static void | operator delete (void *ptr) |
Friends | |
class | TActorSystem |
class | TMockActorContext |
Context object providing actor communication and scheduling capabilities.
TActorContext is passed to actors when they receive messages. It provides methods for sending messages, scheduling future messages, sleeping, and performing request-response patterns.
The context contains information about the current message sender and the actor's own ID. It also manages asynchronous operations through the actor system.
|
inline |
Send a message and wait for a response.
T | Expected response message type |
TQuestion | Question message type |
recipient | Actor to send the question to |
question | Question message to send |
void NNet::NActors::TActorContext::Cancel | ( | TEvent | event | ) |
Cancel a previously scheduled message.
event | Event handle returned by Schedule() |
|
inline |
Forward a typed message to another actor.
T | Message type that has MessageId static member |
to | Recipient actor ID |
args | passed to Message constructor |
Forward a message to another actor (preserves original sender)
to | Recipient actor ID |
messageId | Message type identifier |
blob | Serialized message data |
|
inline |
Schedule a typed message to be delivered at a specific time.
T | Message type that has MessageId static member |
when | Time when the message should be delivered |
sender | Sender actor ID for the scheduled message |
recipient | Recipient actor ID |
args | args passed to the Message constructor |
TEvent NNet::NActors::TActorContext::Schedule | ( | TTime | when, |
TActorId | sender, | ||
TActorId | recipient, | ||
TMessageId | messageId, | ||
TBlob | blob | ||
) |
Schedule a message to be delivered at a specific time.
when | Time when the message should be delivered |
sender | Sender actor ID for the scheduled message |
recipient | Recipient actor ID |
messageId | Message type identifier |
blob | Serialized message data |
|
inline |
Send a typed message to another actor.
T | Message type that has MessageId static member |
to | Recipient actor ID |
args | passed to Message constructor |
Send a message to another actor.
to | Recipient actor ID |
messageId | Message type identifier |
blob | Serialized message data |
|
inline |
Sleep for a specific duration.
Rep | Duration representation type |
Period | Duration period type |
duration | How long to sleep |
|
inline |
Sleep until a specific time.
until | Time to sleep until |
TActorContext::TAsync NNet::NActors::TActorContext::StartAsync | ( | ) |
Start an asynchronous operation context.