-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpipe.h
50 lines (36 loc) · 1.22 KB
/
pipe.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
#pragma once
#include <string>
#include <memory>
#include <queue>
#include <map>
#include "Semaphores.h"
class PCB;
class Pipeline {
private:
class Pipe {
private:
//Z tych semaforów korzystam jak z binarnych
Semaphore readSem;
Semaphore writeSem;
public:
static const unsigned int capacity = 10;
unsigned int spaceLeft = capacity;
std::queue<char> buffer;
std::shared_ptr<PCB> parent;
explicit Pipe(std::shared_ptr<PCB> parent_);
std::string read(const std::shared_ptr<PCB>& readProc, const size_t& size);
int write(const std::shared_ptr<PCB>& writeProc, const std::string& message);
};
std::map<std::string, std::shared_ptr<Pipe>> pipes;
public:
Pipeline() = default;
void create(const std::string& parent, const std::string& mode);
int write(const std::string& p1, const std::string& p2, std::string data);
std::string read(const std::string& p1, const std::string& p2, size_t size);
void remove(const std::string& parent, const std::string& mode);
void remove(const std::string& parent);
bool exists(const std::string& parent, const std::string& mode) const;
bool exists(const std::string& parent) const;
void display();
};
extern Pipeline pipeline;