-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathActorProxy.h
56 lines (45 loc) · 1.29 KB
/
ActorProxy.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#pragma once
#include "CommonDefines.h"
namespace RxActor {
/**
* Immutable handle (proxy) to an Actor, which may or may not reside on the local host or inside the same ActorSystem.
*
* ActorProxy == ActorProxy
*/
template <typename T>
class ActorProxy
: public Templates::Key2<ChannelHandle, ActorId>
, public Templates::ContextDataShared<PublisherChannel<T>>
{
public:
ActorProxy(ChannelHandle t, ActorId u)
: Templates::Key2<ChannelHandle, ActorId>(t, u)
, Templates::ContextDataShared<PublisherChannel<T>>(ChannelFactory::CreatePublisher<T>(t))
{ }
virtual ~ActorProxy()
{ }
virtual void Tell(T msg, ActorProxy<T> sender)
{
// TODO: Include sender.actorId to message
this->context()->Next(msg);
}
virtual bool IsTerminated() const
{
return false;
}
virtual void Forward(T msg, ActorBasePtr context)
{
// To support forwarding I need a special ActorMessage<T> that includes originalSender and intermediateSender
}
virtual ActorPath Path() const
{
return Templates::NameDescription();
}
static ActorProxy NoSender()
{
static std::string a = "no";
static ChannelHandle handle{a, a, a};
return ActorProxy<T>(handle, ActorId::Create());
}
};
}