COROIO: coroio/actors/actorid.hpp Source File
COROIO
 
Loading...
Searching...
No Matches
actorid.hpp
1#pragma once
2
3namespace NNet {
4namespace NActors {
5
7using TLocalActorId = uint32_t;
8
10using TNodeId = uint16_t;
11
13using TCookie = uint16_t;
14
16using TMessageId = uint32_t;
17
29class TActorId {
30public:
32 TActorId() = default;
33
38 operator bool() const {
39 return !((NodeId_ == 0) & (ActorId_ == 0) & (Cookie_ == 0));
40 }
41
43 TNodeId NodeId() const {
44 return NodeId_;
45 }
46
48 TLocalActorId ActorId() const {
49 return ActorId_;
50 }
51
53 TCookie Cookie() const {
54 return Cookie_;
55 }
56
61 std::string ToString() const {
62 return "ActorId:"
63 + std::to_string(NodeId_) + ":"
64 + std::to_string(ActorId_) + ":"
65 + std::to_string(Cookie_);
66 }
67
74 TActorId(TNodeId nodeId, TLocalActorId actorId, TCookie cookie)
75 : NodeId_(nodeId)
76 , ActorId_(actorId)
77 , Cookie_(cookie)
78 { }
79
80private:
81 TLocalActorId ActorId_ = 0;
82 TNodeId NodeId_ = 0;
83 TCookie Cookie_ = 0;
84};
85
92struct THeader {
95 TMessageId MessageId = 0;
96 uint32_t Size = 0;
97};
98
99} // namespace NActors
100} // namespace NNet
Globally unique identifier for actors across a distributed system.
Definition actorid.hpp:29
TNodeId NodeId() const
Get the node ID component.
Definition actorid.hpp:43
TCookie Cookie() const
Get the cookie component.
Definition actorid.hpp:53
TActorId()=default
Default constructor creates an invalid actor ID.
TActorId(TNodeId nodeId, TLocalActorId actorId, TCookie cookie)
Construct actor ID with specific components.
Definition actorid.hpp:74
std::string ToString() const
Convert actor ID to a human-readable string.
Definition actorid.hpp:61
TLocalActorId ActorId() const
Get the local actor ID component.
Definition actorid.hpp:48
Wire header prepended to every remote actor message.
Definition actorid.hpp:92
TActorId Recipient
Destination actor.
Definition actorid.hpp:94
TMessageId MessageId
Message type discriminator.
Definition actorid.hpp:95
uint32_t Size
Payload size in bytes.
Definition actorid.hpp:96
TActorId Sender
Originating actor.
Definition actorid.hpp:93