ladybird/Kernel/FIFO.h
Andreas Kling 85b886c2e0 Make it possible to build the Kernel on a macOS host.
It still requires an ELF compiler and linker, but at least it builds.
I need to get rid of the "Unix" namespace. This does a lot of that.
2018-12-02 23:34:50 +01:00

32 lines
591 B
C++

#pragma once
#include <AK/CircularQueue.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 };
CircularQueue<byte, 16> m_queue;
};