#pragma once
-#include <fcntl.h>
#include <poll.h>
#include <sys/types.h>
-#include <unistd.h>
#include <algorithm>
#include <deque>
#include <folly/Likely.h>
#include <folly/ScopeGuard.h>
#include <folly/SpinLock.h>
+#include <folly/portability/Fcntl.h>
+#include <folly/portability/Unistd.h>
#include <glog/logging.h>
bool active_{false};
};
+ class SimpleConsumer {
+ public:
+ explicit SimpleConsumer(NotificationQueue& queue) : queue_(queue) {
+ ++queue_.numConsumers_;
+ }
+
+ ~SimpleConsumer() {
+ --queue_.numConsumers_;
+ }
+
+ int getFd() const {
+ return queue_.eventfd_ >= 0 ? queue_.eventfd_ : queue_.pipeFds_[0];
+ }
+
+ private:
+ NotificationQueue& queue_;
+ };
+
enum class FdType {
PIPE,
#ifdef FOLLY_HAVE_EVENTFD
auto& data = queue_->queue_.front();
MessageT msg(std::move(data.first));
- auto old_ctx =
- RequestContext::setContext(data.second);
+ RequestContextScopeGuard rctx(std::move(data.second));
queue_->queue_.pop_front();
// Check to see if the queue is empty now.
messageAvailable(std::move(msg));
destroyedFlagPtr_ = nullptr;
- RequestContext::setContext(old_ctx);
-
// If the callback was destroyed before it returned, we are done
if (callbackDestroyed) {
return;