forked from uroni/urbackup_backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MemoryPipe.h
51 lines (36 loc) · 1.17 KB
/
MemoryPipe.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
#ifndef MEMPIPE_H_
#define MEMPIPE_H_
#include "Interface/Pipe.h"
#include <deque>
#include <string>
#include "Interface/Mutex.h"
#include "Interface/Condition.h"
class CMemoryPipe : public IPipe
{
public:
CMemoryPipe(void);
~CMemoryPipe(void);
virtual size_t Read(char *buffer, size_t bsize, int timeoutms);
virtual bool Write(const char *buffer, size_t bsize, int timeoutms, bool flush);
virtual size_t Read(std::string *ret, int timeoutms);
virtual bool Write(const std::string &str, int timeoutms, bool flush);
virtual bool isWritable(int timeoutms);
virtual bool isReadable(int timeoutms);
virtual bool hasError(void);
virtual void shutdown(void);
virtual size_t getNumElements(void);
virtual size_t getNumWaiters();
virtual void addThrottler(IPipeThrottler *throttler);
virtual void addOutgoingThrottler(IPipeThrottler *throttler);
virtual void addIncomingThrottler(IPipeThrottler *throttler);
virtual _i64 getTransferedBytes(void);
virtual void resetTransferedBytes(void);
virtual bool Flush( int timeoutms=-1 );
private:
std::deque<std::string> queue;
IMutex *mutex;
ICondition *cond;
size_t waiters;
bool has_error;
};
#endif /*MEMPIPE_H_*/