-
Notifications
You must be signed in to change notification settings - Fork 0
/
dataServer.h
59 lines (47 loc) · 1.19 KB
/
dataServer.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
#include <iostream>
#include <string>
#include <map>
#include <unistd.h>
#include <fcntl.h>
#include <cstring>
#include <iterator>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <sys/wait.h>
#include <queue>
#include <thread>
#include <dirent.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <pthread.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
// backlog size
#define BACKLOG 1280
// for ease of use
#define SA struct sockaddr
using std::queue;
using std::string;
using std::map;
// execution queue
extern queue<string> clients;
// map of requests for each socket
extern map<int, int> unsatisfied_clients;
// mutex for the map
extern pthread_mutex_t uc_mutex;
// mutex for the thread_pool
extern pthread_mutex_t pool_mutex;
// condition variable if thread_pool is empty
extern pthread_cond_t pool_cond;
// condition variable if thread_pool is full
extern pthread_cond_t full_pool;
// so that helperfunctions.cpp can access these variable
extern int block_size;
extern int thread_pool_size;
extern int queue_size;
// map socket and mutex
extern map<int, pthread_mutex_t> socketmap;
// mutex for this map
extern pthread_mutex_t socket_mutex;