serenity/VirtualFileSystem/NullDevice.cpp
Andreas Kling b0e3f73375 Start refactoring the windowing system to use an event loop.
Userspace programs can now open /dev/gui_events and read a stream of GUI_Event
structs one at a time.

I was stuck on a stupid problem where we'd reenter Scheduler::yield() due to
having one of the has_data_available_for_reading() implementations using locks.
2019-01-14 14:42:49 +01:00

29 lines
438 B
C++

#include "NullDevice.h"
#include "Limits.h"
#include <AK/StdLibExtras.h>
#include <AK/kstdio.h>
NullDevice::NullDevice()
: CharacterDevice(1, 3)
{
}
NullDevice::~NullDevice()
{
}
bool NullDevice::has_data_available_for_reading(Process&) const
{
return true;
}
ssize_t NullDevice::read(byte*, size_t)
{
return 0;
}
ssize_t NullDevice::write(const byte*, size_t bufferSize)
{
return min(GoodBufferSize, bufferSize);
}