Commit a4f059fb authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

let AsyncBase build even without eventfd available

Differential Revision: D32633369

fbshipit-source-id: a4a1df211647a49e0f9e69dac4902f4ae9a5ee27
parent b31f69a0
......@@ -16,7 +16,6 @@
#include <folly/experimental/io/AsyncBase.h>
#include <sys/eventfd.h>
#include <cerrno>
#include <ostream>
#include <stdexcept>
......@@ -31,6 +30,10 @@
#include <folly/String.h>
#include <folly/portability/Unistd.h>
#if __has_include(<sys/eventfd.h>)
#include <sys/eventfd.h>
#endif
namespace folly {
AsyncBaseOp::AsyncBaseOp(NotificationCallback cb)
......@@ -93,8 +96,12 @@ AsyncBase::AsyncBase(size_t capacity, PollMode pollMode) : capacity_(capacity) {
CHECK_GT(capacity_, 0);
completed_.reserve(capacity_);
if (pollMode == POLLABLE) {
#if __has_include(<sys/eventfd.h>)
pollFd_ = eventfd(0, EFD_NONBLOCK);
checkUnixError(pollFd_, "AsyncBase: eventfd creation failed");
#else
// fallthrough to not-pollable, observed as: pollFd() == -1
#endif
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment