1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:27:44 +00:00
serenity/Kernel/FIFO.h
Andreas Kling f1404aa948 Add primitive FIFO and hook it up to sys$pipe().
It's now possible to do this in bash:

cat kernel.map | fgrep List

This is very cool! :^)
2018-11-12 01:28:46 +01:00

31 lines
615 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);
Unix::ssize_t write(const byte*, Unix::size_t);
Unix::ssize_t read(byte*, Unix::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;
};