1 #ifndef MSP_IO_EVENTREADER_H_
2 #define MSP_IO_EVENTREADER_H_
4 #include <msp/core/noncopyable.h>
11 Helper class for reading data in a way that supports events. For internal use
14 On Windows, overlapped reads are used. Data is read to an internal buffer and
15 handed out from there. An event object is kept synchronized with the buffer
16 state to get level-triggered semantics for poll. Whenever the buffer becomes
17 empty, a new overlapped read is started.
19 Unix-based systems can poll the fd directly, so this class reduces to a simple
20 passthrough to sys_read.
22 class EventReader: private NonCopyable
28 Private *priv = nullptr;
31 EventReader(Handle &, std::size_t);
34 const Handle &get_event();
38 unsigned read(char *, std::size_t);