Commit a42fb197 authored by Andreas Schmidt's avatar Andreas Schmidt

Add Python bindings for all receive calls.

parent ddfe37d0
Pipeline #1808 failed with stages
in 1 minute and 18 seconds
from libc.stdint cimport uint32_t, uint16_t, uint8_t, int32_t
from libc.stdlib cimport malloc, free
from posix.time cimport timespec
cimport cprrt
......@@ -189,6 +190,36 @@ cdef class PrrtSocket:
len = cprrt.PrrtSocket_recv(self._c_socket, <void*> buffer)
return buffer[:len]
def receive_asap(self):
cdef char buffer[65536]
cdef int32_t len
with nogil:
len = cprrt.PrrtSocket_receive_asap(self._c_socket, <void*> buffer)
return buffer[:len]
def receive_asap_wait(self):
cdef char buffer[65536]
cdef int32_t len
with nogil:
len = cprrt.PrrtSocket_receive_asap_wait(self._c_socket, <void*> buffer)
return buffer[:len]
def receive_asap_timedwait(self, deadline):
cdef char buffer[65536]
cdef int32_t len
cdef timespec deadline_timespec = timespec(deadline.seconds, deadline.microseconds * 1000)
with nogil:
len = cprrt.PrrtSocket_receive_asap_timedwait(self._c_socket, <void*> buffer, &deadline_timespec)
return buffer[:len]
def receive_ordered(self, time_window):
cdef char buffer[65536]
cdef int32_t len
cdef uint32_t time_window_us = time_window * (1000**2)
with nogil:
len = cprrt.PrrtSocket_receive_ordered(self._c_socket, <void*> buffer, time_window_us)
return buffer[:len]
def receive_ordered_wait(self, time_window):
cdef char buffer[65536]
cdef int32_t len
......@@ -197,6 +228,15 @@ cdef class PrrtSocket:
len = cprrt.PrrtSocket_receive_ordered_wait(self._c_socket, <void*> buffer, time_window_us)
return buffer[:len]
def receive_ordered_timedwait(self, time_window, deadline):
cdef char buffer[65536]
cdef int32_t len
cdef uint32_t time_window_us = time_window * (1000**2)
cdef timespec deadline_timespec = timespec(deadline.seconds, deadline.microseconds * 1000)
with nogil:
len = cprrt.PrrtSocket_receive_ordered_timedwait(self._c_socket, <void*> buffer, time_window_us, &deadline_timespec)
return buffer[:len]
def connect(self, host, port):
cdef bytes encodedHost = host.encode("utf-8")
cprrt.PrrtSocket_connect(self._c_socket, encodedHost, port)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment