From fedfeaced48150e27907628244e95ca54dbe7c02 Mon Sep 17 00:00:00 2001 From: Determinant Date: Fri, 28 Jun 2019 17:10:36 -0400 Subject: more api --- src/event.cpp | 24 ++++++++++++++++++++++++ src/msg.cpp | 8 +++++--- 2 files changed, 29 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/event.cpp b/src/event.cpp index 2fe2861..18aca18 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -69,6 +69,30 @@ void timerev_del(timerev_t *self) { self->del(); } void timerev_clear(timerev_t *self) { self->clear(); } +mpscqueue_t *mpscqueue_new() { return new mpscqueue_t(); } + +void mpscqueue_free(mpscqueue_t *self) { delete self; } + +void mpscqueue_reg_handler(mpscqueue_t *self, const eventcontext_t *ec, mpscqueue_callback_t callback, void *userdata) { + self->reg_handler(*ec, [=](mpscqueue_t &q) { + return callback(&q, userdata); + }); +} + +void mpscqueue_unreg_handler(mpscqueue_t *self) { self->unreg_handler(); } + +bool mpscqueue_enqueue(mpscqueue_t *self, void *elem, bool unbounded) { + return self->enqueue(elem, unbounded); +} + +bool mpscqueue_try_dequeue(mpscqueue_t *self, void **elem) { + return self->try_dequeue(*elem); +} + +void mpscqueue_set_capacity(mpscqueue_t *self, size_t cap) { + self->set_capacity(cap); +} + } #endif diff --git a/src/msg.cpp b/src/msg.cpp index be5b4b1..7ad0629 100644 --- a/src/msg.cpp +++ b/src/msg.cpp @@ -14,9 +14,11 @@ datastream_t *msg_consume_payload(const msg_t *msg) { return new datastream_t(msg->get_payload()); } -_opcode_t msg_get_opcode(const msg_t *msg) { - return msg->get_opcode(); -} +_opcode_t msg_get_opcode(const msg_t *self) { return self->get_opcode(); } + +uint32_t msg_get_magic(const msg_t *self) { return self->get_magic(); } + +void msg_set_magic(msg_t *self, uint32_t magic) { return self->set_magic(magic); } } -- cgit v1.2.3-70-g09d2