-
Notifications
You must be signed in to change notification settings - Fork 3
/
UDPConnection.h
47 lines (43 loc) · 1.15 KB
/
UDPConnection.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
#pragma once
#include <list>
#include <queue>
#include "Connection.h"
#include "ConnectionOptions.h"
#include "Generator.h"
class OpQueue {
public:
size_t size();
void pop(Operation *op);
void push(Operation op);
Operation *find(uint16_t req_id);
Operation *earliest_last_xmit(void);
std::list<Operation>::iterator begin();
std::list<Operation>::iterator end();
private:
std::list<Operation> list;
};
class UDPConnection : public Connection {
public:
UDPConnection(struct event_base* base, string hostname, int port, options_t options, bool sampling);
void drive_write_machine(double now = 0.0);
void retransmit(double now);
void issue_something(double now);
void issue_something(Operation &op);
void issue_get(string *key, double now);
void issue_get(Operation &op);
void timer_callback(void);
void read_callback(void);
void pop_op(Operation *op);
Operation *consume_udp_binary_response(char *buf, size_t length);
private:
int fd;
uint16_t req_id = 0;
KeyGenerator *keygen;
double next_time;
Generator *iagen;
options_t options;
struct event *timer;
OpQueue op_queue;
enum read_state_enum read_state;
enum write_state_enum write_state;
};