Expose Duration units and add a Nanoseconds function to let us build against 0.6.0
This commit is contained in:
@@ -101,7 +101,14 @@ ctypedef Promise[PyArray] PyPromiseArray
|
|||||||
|
|
||||||
cdef extern from "kj/time.h" namespace " ::kj":
|
cdef extern from "kj/time.h" namespace " ::kj":
|
||||||
cdef cppclass Duration:
|
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:
|
# cdef cppclass TimePoint:
|
||||||
# TimePoint(Duration)
|
# TimePoint(Duration)
|
||||||
cdef cppclass Timer:
|
cdef cppclass Timer:
|
||||||
@@ -109,6 +116,9 @@ cdef extern from "kj/time.h" namespace " ::kj":
|
|||||||
# VoidPromise atTime(TimePoint time)
|
# VoidPromise atTime(TimePoint time)
|
||||||
VoidPromise afterDelay(Duration delay)
|
VoidPromise afterDelay(Duration delay)
|
||||||
|
|
||||||
|
cdef inline Duration Nanoseconds(int64_t nanos):
|
||||||
|
return NANOSECONDS * nanos
|
||||||
|
|
||||||
cdef extern from "kj/async-io.h" namespace " ::kj":
|
cdef extern from "kj/async-io.h" namespace " ::kj":
|
||||||
cdef cppclass AsyncIoStream:
|
cdef cppclass AsyncIoStream:
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1688,7 +1688,7 @@ cdef class _Timer:
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
cpdef after_delay(self, time) except +reraise_kj_exception:
|
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():
|
def getTimer():
|
||||||
return _Timer()._init(helpers.getTimer(C_DEFAULT_EVENT_LOOP_GETTER().thisptr))
|
return _Timer()._init(helpers.getTimer(C_DEFAULT_EVENT_LOOP_GETTER().thisptr))
|
||||||
|
|||||||
Reference in New Issue
Block a user