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();
18 Poller(const Poller&) = delete;
19 Poller(Poller&&) = delete;
20 Poller& operator=(const Poller&) = delete;
21 Poller& operator=(Poller&&) = delete;
22 ~Poller();
23
24#ifndef _WIN32
28 [[nodiscard]] bool poll(int fd);
29#endif
30
33 [[nodiscard]] bool aborted() const {
34 return abortFlag;
35 }
36
39 void abort();
40
43 void reset() {
44 abortFlag = false;
45 }
46
47private:
48#ifndef _WIN32
49 std::array<int, 2> wakeupPipe;
50#endif
51 std::atomic_bool abortFlag = false;
52};
53
54} // namespace openmsx
55
56#endif
Polls for events on a given file descriptor.
Definition Poller.hh:15
Poller(const Poller &)=delete
Poller(Poller &&)=delete
Poller & operator=(Poller &&)=delete
bool poll(int fd)
Waits for an event to occur on the given file descriptor.
Definition Poller.cc:42
Poller & operator=(const Poller &)=delete
void reset()
Reset aborted() to false.
Definition Poller.hh:43
bool aborted() const
Returns true iff abort() was called.
Definition Poller.hh:33
void abort()
Aborts a poll in progress and any future poll attempts.
Definition Poller.cc:30
This file implemented 3 utility functions:
Definition Autofire.cc:11