From a6fd9a69e7814d75195bbbd2a699ed7a6c66ec38 Mon Sep 17 00:00:00 2001 From: Andrii Grynenko Date: Wed, 4 May 2016 14:32:54 -0700 Subject: [PATCH] folly::Future integration with Python Summary: This diff implements two functions which can be used to bridge C++ asynchronous APIs with Python. 1. getExecutor(event_loop) allows extracting a folly::Executor-compatible object from Python event_loop. 2. wrapFuture wraps any folly::Future object in a Python Future object. Reviewed By: ambv Differential Revision: D2878731 fb-gh-sync-id: 83628b6b24d6039999f88c5de441e41064b2417e fbshipit-source-id: 83628b6b24d6039999f88c5de441e41064b2417e --- folly/io/async/NotificationQueue.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/folly/io/async/NotificationQueue.h b/folly/io/async/NotificationQueue.h index 4714ef8d..acbd3c37 100644 --- a/folly/io/async/NotificationQueue.h +++ b/folly/io/async/NotificationQueue.h @@ -213,6 +213,24 @@ class NotificationQueue { 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 -- 2.34.1