-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathManager.h
More file actions
52 lines (40 loc) · 1.21 KB
/
Manager.h
File metadata and controls
52 lines (40 loc) · 1.21 KB
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
#ifndef PROJECT_TEMPLATE_MANAGER_H
#define PROJECT_TEMPLATE_MANAGER_H
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <time.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <vector>
#include <queue>
#include <unordered_map>
#include <mutex>
#include <iostream>
#include <pthread.h>
#include <thread>
#include <condition_variable>
using namespace std;
// This is set to true at the beginning of the program.
// As soon as we receive the signal to start the program, then we can set it to false
// and all processes can start sending proper messages instead of initialization messages.
// the access to this variable is protected by a mutex
extern mutex mtx_initialization_phase;
extern bool initialization_phase;
class Manager {
vector<int> ports;
vector<char*> ips;
vector<int> processes;
int process_number;
int number_of_messages;
unordered_map<int,int> port_id;
public:
Manager(vector<int> &ports, vector<char *> &ips, vector<int> &processes, int process_number,
int number_of_messages); // Constructor
void run();
};
#endif //PROJECT_TEMPLATE_MANAGER_H