Initial wrapping of kj/async Promises and EventLoop

This commit is contained in:
Jason Paryani
2013-09-15 16:52:34 -07:00
parent fa5fe5a92c
commit d4150227a7
4 changed files with 135 additions and 0 deletions

31
capnp/async_cpp.pxd Normal file
View File

@@ -0,0 +1,31 @@
# schema.capnp.cpp.pyx
# distutils: language = c++
# distutils: extra_compile_args = --std=c++11
from cpython.ref cimport PyObject
cdef extern from "kj/exception.h" namespace " ::kj":
cdef cppclass Exception:
pass
cdef extern from "kj/async.h" namespace " ::kj":
cdef cppclass Promise[T]:
Promise(Promise)
T wait()
ctypedef Promise[PyObject *] PyPromise
cdef extern from "kj/async.h" namespace " ::kj":
cdef cppclass EventLoop:
EventLoop()
# Promise[void] yieldFrom'yield'()
object wait(PyPromise)
object there(PyPromise)
PyPromise evalLater(PyObject * func)
PyPromise there(PyPromise, PyObject * func)
cdef cppclass SimpleEventLoop(EventLoop):
pass
cdef extern from "asyncHelper.h":
PyPromise evalLater(EventLoop &, PyObject * func)
PyPromise there(EventLoop & loop, PyPromise & promise, PyObject * func, PyObject * error_func)