-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtcp_node.h
71 lines (57 loc) · 1.82 KB
/
tcp_node.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef TCP_NODE_H
#define TCP_NODE_H
#include "node_config.h"
#include "piece.h"
#include "gopp/gopp.h"
#include "gopp/channels.h"
namespace felis {
namespace tcp {
class NodeServerRoutine;
class ReceiverChannel;
class SendChannel;
}
class TcpNodeTransport : public PromiseRoutineTransportService {
static NodeConfiguration &node_config() {
return util::Instance<NodeConfiguration>();
}
friend class tcp::NodeServerRoutine;
tcp::NodeServerRoutine *serv;
std::array<go::TcpSocket *, kMaxNrNode> incoming_socks;
std::array<go::TcpSocket *, kMaxNrNode> outgoing_socks;
std::array<tcp::SendChannel *, kMaxNrNode> outgoing_channels;
std::array<tcp::ReceiverChannel *, kMaxNrNode> incoming_connection;
/**
* To handle transport request of local Routines.
*/
LocalTransport ltp;
std::atomic_int counters = 0;
public:
TcpNodeTransport();
/**
* Transport remote and local PieceRoutines. For remote PieceRoutines, encode and write the corresponding OutChannel.
* For local PieceRoutines, use LocalTransport.
* @param routine The PieceRoutine to be transported.
*/
void TransportPromiseRoutine(PieceRoutine *routine) final override;
void TransportFutureValue(BaseFutureValue *val) final override;
void TransportDistributedFutureValue(BaseFutureValue *val, int origin_node) final override;
void FinishCompletion(int level) final override;
bool PeriodicIO(int core) final override;
void PrefetchInbound() final override;
uint8_t GetNumberOfNodes() final override {
return node_config().nr_nodes();
}
void OnCounterReceived();
};
}
namespace util {
template <>
struct InstanceInit<felis::TcpNodeTransport> {
static constexpr bool kHasInstance = true;
static inline felis::TcpNodeTransport *instance;
InstanceInit() {
instance = new felis::TcpNodeTransport();
}
};
}
#endif