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