| 1 |
#ifndef POLLER_HH |
| 2 |
#define POLLER_HH |
| 3 |
|
| 4 |
#include <array> |
| 5 |
#include <atomic> |
| 6 |
|
| 7 |
namespace openmsx { |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
class Poller |
| 15 |
{ |
| 16 |
public: |
| 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 |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
[[nodiscard]] bool poll(int fd); |
| 29 |
#endif |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
[[nodiscard]] bool aborted() const { |
| 34 |
return abortFlag; |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
void abort(); |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
void reset() { |
| 44 |
abortFlag = false; |
| 45 |
} |
| 46 |
|
| 47 |
private: |
| 48 |
#ifndef _WIN32 |
| 49 |
std::array<int, 2> wakeupPipe; |
| 50 |
#endif |
| 51 |
std::atomic_bool abortFlag = false; |
| 52 |
}; |
| 53 |
|
| 54 |
} |
| 55 |
|
| 56 |
#endif |