1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
#ifndef LIBFILEZILLA_UNIX_POLLER_HEADER
#define LIBFILEZILLA_UNIX_POLLER_HEADER
#include "../libfilezilla/libfilezilla.hpp"
#include "../libfilezilla/mutex.hpp"
#if !FZ_WINDOWS
#include <poll.h>
namespace fz {
class poller final
{
public:
poller() = default;
poller(poller const&) = delete;
poller& operator=(poller const&) = delete;
~poller();
// zero on success, else errno
int init();
// Must call locked
bool wait(scoped_lock & l);
// fds must be large enough to hold n+1 entries, but fds[n] must not be filled by caller
bool wait(struct pollfd *fds, nfds_t n, scoped_lock & l);
void interrupt(scoped_lock & l);
#if defined(HAVE_EVENTFD)
int event_fd_{-1};
#else
// A pipe is used to unblock poll
int pipe_[2]{-1, -1};
#endif
condition cond_;
bool signalled_{};
bool idle_wait_{};
};
}
#else
#error poller.hpp is not for Windows
#endif
#endif
|