Commit a6fd9a69 authored by Andrii Grynenko's avatar Andrii Grynenko Committed by Facebook Github Bot 6

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
parent 9a47ba11
...@@ -213,6 +213,24 @@ class NotificationQueue { ...@@ -213,6 +213,24 @@ class NotificationQueue {
bool active_{false}; 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 { enum class FdType {
PIPE, PIPE,
#ifdef FOLLY_HAVE_EVENTFD #ifdef FOLLY_HAVE_EVENTFD
......
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