openMSX
Poller.hh
Go to the documentation of this file.
1#ifndef POLLER_HH
2#define POLLER_HH
3
4#include <array>
5#include <atomic>
6
7namespace openmsx {
8
14class Poller
15{
16public:
17 Poller(const Poller&) = delete;
18 Poller& operator=(const Poller&) = delete;
19
20 Poller();
21 ~Poller();
22
23#ifndef _WIN32
27 [[nodiscard]] bool poll(int fd);
28#endif
29
32 [[nodiscard]] bool aborted() const {
33 return abortFlag;
34 }
35
38 void abort();
39
42 void reset() {
43 abortFlag = false;
44 }
45
46private:
47#ifndef _WIN32
48 std::array<int, 2> wakeupPipe;
49#endif
50 std::atomic_bool abortFlag;
51};
52
53} // namespace openmsx
54
55#endif
Polls for events on a given file descriptor.
Definition Poller.hh:15
Poller(const Poller &)=delete
bool poll(int fd)
Waits for an event to occur on the given file descriptor.
Definition Poller.cc:43
Poller & operator=(const Poller &)=delete
void reset()
Reset aborted() to false.
Definition Poller.hh:42
bool aborted() const
Returns true iff abort() was called.
Definition Poller.hh:32
void abort()
Aborts a poll in progress and any future poll attempts.
Definition Poller.cc:31
This file implemented 3 utility functions:
Definition Autofire.cc:11