]> git.sesse.net Git - greproxy/blob - pacer.h
Merge branch 'master' of /srv/git.sesse.net/www/greproxy
[greproxy] / pacer.h
1 #ifndef _PACER_H
2 #define _PACER_H 1
3
4 #include <stdint.h>
5 #include <sys/time.h>
6 #include <deque>
7 #include <string>
8
9 #include "protocol.h"
10 #include "reorderer.h"
11
12 struct Pacer : public Sender {
13 public:
14         Pacer(Sender *sender, int max_rate_kbit_per_sec, int burst_num_packets);
15         virtual void send_packet(uint16_t proto, const std::string &data, uint32_t incoming_seq);
16
17         void possibly_adjust_tv(timeval *tv);
18         void possibly_flush_packets();
19
20 private:
21         Sender *sender;
22         int burst_num_packets;
23         double seconds_per_byte;
24         timeval next_send_packet;
25         std::deque<GREPacket> waiting_packets;
26 };
27
28 #endif  // !defined(_PACER_H)