From: Andrii Grynenko Date: Wed, 4 May 2016 21:32:54 +0000 (-0700) Subject: folly::Future integration with Python X-Git-Tag: 2016.07.26~280 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a6fd9a69e7814d75195bbbd2a699ed7a6c66ec38;p=folly.git 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 --- 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