|
TEC
A lightweight C++ library enabling safe, efficient execution in multithreaded and concurrent systems.
|
Abstract base class defining the actor lifecycle and request handling interface. More...
#include <tec_actor.hpp>
Public Member Functions | |
| Actor ()=default | |
| Default constructor. | |
| Actor (const Actor &)=delete | |
| Deleted copy constructor. | |
| Actor (Actor &&)=delete | |
| Deleted move constructor. | |
| Actor & | operator= (const Actor &)=delete |
| Deleted copy assignment operator. | |
| Actor & | operator= (Actor &&)=delete |
| Deleted move assignment operator. | |
| virtual | ~Actor ()=default |
| Virtual destructor. | |
| virtual void | start (Signal *sig_started, Status *status)=0 |
| Starts the actor's operation. | |
| virtual void | shutdown (Signal *sig_stopped)=0 |
| Initiates graceful shutdown of the actor. | |
| virtual Status | process_request (Request request, Reply reply)=0 |
| Processes a single request and produces a reply. | |
| virtual Status | run () |
| Mimics Daemon's behavior. | |
| virtual Status | terminate () |
| Mimics Daemon's behavior. | |
Abstract base class defining the actor lifecycle and request handling interface.
All concrete actors must inherit from this class and implement:
start() – asynchronous initialization with completion signal.shutdown() – graceful termination with completion signal.process_request() – core message handling logic.Actors are typically long-lived services (e.g., gRPC servers, workers) that run in their own thread or event loop until explicitly shut down.
|
default |
Default constructor.
Initializes base actor state. Derived classes should perform minimal setup here and defer heavy initialization to start().
Deleted copy constructor.
Actors represent unique service instances and must not be copied.
|
delete |
Deleted move constructor.
Prevents accidental transfer of actor ownership.
|
virtualdefault |
Virtual destructor.
Ensures proper destruction of derived classes when deleted through a base pointer. Derived classes should override if cleanup is needed.
Processes a single request and produces a reply.
This is the core message handling entry point. Implementations should:
requestreply with resultsStatus| request | [in] Input message to process (moved-from if possible). |
| reply | [out] Output message populated with response. |
Implemented in tec::GrpcClient< TParams, Traits >, tec::SocketClient< TParams >, tec::SocketClientNd< TParams >, tec::SocketServer< TParams >, tec::SocketServer< Params >, and tec::GrpcServer< TParams, Traits >.
Initiates graceful shutdown of the actor.
Requests the actor to stop processing new requests, complete in-flight work, and terminate cleanly. Completion is signaled via sig_stopped.
| sig_stopped | [in,out] Signal set when shutdown is fully complete. Must remain valid until triggered. |
Implemented in tec::GrpcClient< TParams, Traits >, tec::GrpcServer< TParams, Traits >, tec::SocketClient< TParams >, tec::SocketServer< TParams >, and tec::SocketServer< Params >.
Starts the actor's operation.
This method initiates the actor's internal service (e.g., binding ports, starting threads, entering event loop). It must not block indefinitely unless the actor is designed to run until shutdown() is called.
Completion (success or failure) is signaled via sig_started.
| sig_started | [in,out] Signal set when startup completes. Must remain valid until the signal is triggered. |
| status | [out] Filled with result:
|
sig_started->wait() to synchronize. shutdown() is invoked from another thread.Implemented in tec::GrpcClient< TParams, Traits >, tec::GrpcServer< TParams, Traits >, tec::SocketClient< TParams >, tec::SocketServer< TParams >, and tec::SocketServer< Params >.