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 53 54 55
|
#ifndef LIBFILEZILLA_WINDOWS_POLLER_HEADER
#define LIBFILEZILLA_WINDOWS_POLLER_HEADER
#include "../libfilezilla/libfilezilla.hpp"
#if FZ_WINDOWS
#include "../libfilezilla/glue/windows.hpp"
#include "../libfilezilla/mutex.hpp"
#include <winsock2.h>
namespace fz {
struct pollinfo
{
intptr_t fd_{-1};
int events_{};
WSANETWORKEVENTS result_{};
};
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);
bool wait(pollinfo* fds, size_t n, scoped_lock& l);
void interrupt(scoped_lock& l);
WSAEVENT sync_event_{WSA_INVALID_EVENT};
condition cond_;
bool signalled_{};
bool idle_wait_{};
};
}
#else
#error windows/poller.hpp is not for non-Windows
#endif
#endif
|