mirror of
https://github.com/commaai/msgq.git
synced 2026-06-10 06:54:13 +08:00
* Implementation of FakeSubSocket and FakePubSocket using eventfd with support for one-in/one-out synchronization * Expose FakeEvent to Python * Add demo showcasing synchronization between processes * Fix linter errors * Expose more FakeEvent APIs in Python bindings * Add FakePoller implementation * Remove suffix from poll env vars * Set poller timeout to zero when events are enabled * Replace poll with ppoll. Add invalidation methods * Fix lint issues * Fix comment indent * Remove fake_demo * Remove FakePubSocket. Simpler FakePoller implementation. Ability to wait for multiple events * Rename FakeEvent to Event and move it to event.cc * Rename event purpose constants in py * Add support for timeout in wait methods * Add tests for events and fake sockets * Fix lint errors * Add zmq sleeps * Temporarly disable TestFakeSockets on ZMQ * Add exception type specifiers to test_fake * Event Manager implementation * Fix fake sockets tests * Update EventManager API * Add test for enable/disable * Add tests for cereal prefix * Remove EventPurpose from python bindings * Fix lint issues * event_state_shm_mmap implementation shared by EventManager and FakeSubSocket * Rename EventManager to SocketEventHandle * More renames
69 lines
1.5 KiB
Cython
69 lines
1.5 KiB
Cython
# distutils: language = c++
|
|
#cython: language_level=3
|
|
|
|
from libcpp.string cimport string
|
|
from libcpp.vector cimport vector
|
|
from libcpp cimport bool
|
|
|
|
|
|
cdef extern from "cereal/messaging/impl_fake.h":
|
|
cdef cppclass Event:
|
|
@staticmethod
|
|
int wait_for_one(vector[Event], int) except +
|
|
|
|
Event()
|
|
Event(int)
|
|
void set()
|
|
int clear()
|
|
void wait(int) except +
|
|
bool peek()
|
|
int fd()
|
|
|
|
cdef cppclass SocketEventHandle:
|
|
@staticmethod
|
|
void toggle_fake_events(bool)
|
|
@staticmethod
|
|
void set_fake_prefix(string)
|
|
@staticmethod
|
|
string fake_prefix()
|
|
|
|
SocketEventHandle(string, string, bool)
|
|
bool is_enabled()
|
|
void set_enabled(bool)
|
|
Event recv_called()
|
|
Event recv_ready()
|
|
|
|
|
|
cdef extern from "cereal/messaging/messaging.h":
|
|
cdef cppclass Context:
|
|
@staticmethod
|
|
Context * create()
|
|
|
|
cdef cppclass Message:
|
|
void init(size_t)
|
|
void init(char *, size_t)
|
|
void close()
|
|
size_t getSize()
|
|
char *getData()
|
|
|
|
cdef cppclass SubSocket:
|
|
@staticmethod
|
|
SubSocket * create()
|
|
int connect(Context *, string, string, bool)
|
|
Message * receive(bool)
|
|
void setTimeout(int)
|
|
|
|
cdef cppclass PubSocket:
|
|
@staticmethod
|
|
PubSocket * create()
|
|
int connect(Context *, string)
|
|
int sendMessage(Message *)
|
|
int send(char *, size_t)
|
|
bool all_readers_updated()
|
|
|
|
cdef cppclass Poller:
|
|
@staticmethod
|
|
Poller * create()
|
|
void registerSocket(SubSocket *)
|
|
vector[SubSocket*] poll(int) nogil
|