-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnet.hpp
54 lines (44 loc) · 1.19 KB
/
net.hpp
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
#ifndef NET_HPP
#define NET_HPP
#include <string>
#include <vector>
#include <thread>
#include <deque>
#include <mutex>
#include <condition_variable>
#include "imgio.h"
using namespace std;
struct ImageServerConf {
string host;
string port;
double timeout;
ImageServerConf(string host, string port, double timeout);
};
typedef enum {
IM_OP_RAW,
IM_OP_DECODE,
IM_OP_YUV_DECODE
} ImageOp;
class ImageMultiClient {
private:
vector< ImageServerConf > servers;
vector< deque< Image* > > queues;
vector< thread > threads;
vector< long > mem_usage;
mutex queues_mutex;
recursive_mutex advance_mutex;
condition_variable queues_condition;
ImageOp op;
volatile bool running;
public:
ImageMultiClient(const vector< ImageServerConf > &servers, ImageOp op=IM_OP_DECODE);
~ImageMultiClient();
void worker(int shard);
vector< const Image* > advance_to_timestamp(double timestamp, bool block=false, bool empty=false);
vector< const Image* > advance_to_stream(int shard, bool block=false, bool empty=false);
vector< const Image* > advance_to_last(bool block=false, bool empty=false);
vector< tuple< double, int, int > > get_status();
void print_status();
void stop();
};
#endif