blob: 30a5bd33df2805252c9956aa4eb2d92b94464126 (
plain)
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
|
#pragma once
#include "DoubleBuffer.h"
#include <AK/Retainable.h>
#include <AK/RetainPtr.h>
#include <VirtualFileSystem/UnixTypes.h>
class FIFO : public Retainable<FIFO> {
public:
enum Direction {
Neither, Reader, Writer
};
static RetainPtr<FIFO> create();
void open(Direction);
void close(Direction);
ssize_t write(const byte*, size_t);
ssize_t read(byte*, size_t);
bool can_read() const;
bool can_write() const;
private:
FIFO();
unsigned m_writers { 0 };
unsigned m_readers { 0 };
DoubleBuffer m_buffer;
};
|