Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(546)

Unified Diff: mojo/public/python/src/python_system_helper.h

Issue 573253002: mojo: Add async waiter for python bindings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/public/python/src/python_system_helper.h
diff --git a/mojo/public/python/src/python_system_helper.h b/mojo/public/python/src/python_system_helper.h
index 1962ba787fa067f5c95f79960eefecee041d56a7..6b13954b2839f25048a8213938ccd11153c5b4f6 100644
--- a/mojo/public/python/src/python_system_helper.h
+++ b/mojo/public/python/src/python_system_helper.h
@@ -5,18 +5,44 @@
#ifndef MOJO_PUBLIC_PYTHON_SRC_PYTHON_SYSTEM_HELPER_H_
#define MOJO_PUBLIC_PYTHON_SRC_PYTHON_SYSTEM_HELPER_H_
+#include <map>
+
#include "Python.h"
+#include "mojo/public/c/environment/async_waiter.h"
+#include "mojo/public/c/system/types.h"
#include "mojo/public/cpp/bindings/callback.h"
+#include "mojo/public/cpp/bindings/lib/shared_ptr.h"
namespace mojo {
+namespace python {
// Create a mojo::Closure from a callable python object.
mojo::Closure BuildClosure(PyObject* callable);
-// Initalize mojo::RunLoop
-void InitRunLoop();
+class PythonAsyncWaiter {
+ public:
+ PythonAsyncWaiter();
+ ~PythonAsyncWaiter();
+ MojoAsyncWaitID AsyncWait(MojoHandle handle,
+ MojoHandleSignals signals,
+ MojoDeadline deadline,
+ PyObject* callable);
+
+ void CancelWait(MojoAsyncWaitID wait_id);
+
+ private:
+ class AsyncWaiterRunnable;
+
+ typedef std::map<MojoAsyncWaitID,
+ internal::SharedPtr<mojo::Callback<void(MojoResult)> > >
+ CallbackMap;
+
+ CallbackMap callbacks_;
+ const MojoAsyncWaiter* async_waiter_;
+};
+} // namespace python
} // namespace mojo
#endif // MOJO_PUBLIC_PYTHON_SRC_PYTHON_SYSTEM_HELPER_H_

Powered by Google App Engine
This is Rietveld 408576698