Add a kqueue poller for keep-alive parking on macOS and FreeBSD

KqueuePoller keeps the Poller contract with EV_ONESHOT, which deletes an
event once it is delivered, so arm() adds it each time. wake() uses the
socket pair that PollPoller uses, since EVFILT_USER is not on every BSD.
make_poller() picks it on macOS and FreeBSD and falls back to poll()
elsewhere.

The contract tests now run on it as well.
This commit is contained in:
yhirose committed 2026-11-21 00:26:30 -05:00
1 parent f92079e633
commit ddaeb5d83d
2 files changed
+115 -1

No files matched your search

+3
View File
@@ -33938,6 +33938,9 @@ std::vector<PollerBackend> poller_backends() {
{"poll", &detail::PollPoller::create},
#ifdef __linux__
{"epoll", &detail::EpollPoller::create},
#endif
#ifdef CPPHTTPLIB_KQUEUE_POLLER
{"kqueue", &detail::KqueuePoller::create},
#endif
};
}