From fbc17674750c1ffd02db1a4d9f971e72d66eafb1 Mon Sep 17 00:00:00 2001 From: Ben Moran Date: Thu, 8 Jun 2017 12:01:11 +0100 Subject: [PATCH] Expose Duration units and add a Nanoseconds function to let us build against 0.6.0 --- capnp/includes/capnp_cpp.pxd | 12 +++++++++++- capnp/lib/capnp.pyx | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/capnp/includes/capnp_cpp.pxd b/capnp/includes/capnp_cpp.pxd index e4f5675..9e4f437 100644 --- a/capnp/includes/capnp_cpp.pxd +++ b/capnp/includes/capnp_cpp.pxd @@ -101,7 +101,14 @@ ctypedef Promise[PyArray] PyPromiseArray cdef extern from "kj/time.h" namespace " ::kj": cdef cppclass Duration: - Duration(int64_t) + Duration operator*(int64_t) + Duration NANOSECONDS + Duration MICROSECONDS + Duration MILLISECONDS + Duration SECONDS + Duration MINUTES + Duration HOURS + Duration DAYS # cdef cppclass TimePoint: # TimePoint(Duration) cdef cppclass Timer: @@ -109,6 +116,9 @@ cdef extern from "kj/time.h" namespace " ::kj": # VoidPromise atTime(TimePoint time) VoidPromise afterDelay(Duration delay) +cdef inline Duration Nanoseconds(int64_t nanos): + return NANOSECONDS * nanos + cdef extern from "kj/async-io.h" namespace " ::kj": cdef cppclass AsyncIoStream: pass diff --git a/capnp/lib/capnp.pyx b/capnp/lib/capnp.pyx index f25eb6c..aa23137 100644 --- a/capnp/lib/capnp.pyx +++ b/capnp/lib/capnp.pyx @@ -1688,7 +1688,7 @@ cdef class _Timer: return self cpdef after_delay(self, time) except +reraise_kj_exception: - return _VoidPromise()._init(self.thisptr.afterDelay(capnp.Duration(time))) + return _VoidPromise()._init(self.thisptr.afterDelay(capnp.Nanoseconds(time))) def getTimer(): return _Timer()._init(helpers.getTimer(C_DEFAULT_EVENT_LOOP_GETTER().thisptr))