-
Notifications
You must be signed in to change notification settings - Fork 2
/
tcp_node.h
61 lines (47 loc) · 1.36 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
#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;
LocalTransport ltp;
std::atomic_int counters = 0;
public:
TcpNodeTransport();
void TransportPromiseRoutine(PieceRoutine *routine) 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