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
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