79 .average_message_size = 0,
101 for(
size_t i = 0; i < teardown_notifiers; ++i) {
124 if(alloc_size < min_size) {
125 alloc_size = min_size;
133 if(!
mq->first_page) {
134 mq->first_page = page;
138 mq->last_page->
next = page;
141 mq->last_page = page;
231 if(msg_in_page->
size <= msg->
size) {
250 for(
size_t i = 0; i < teardown_notifiers; ++i) {
253 if(existing == notifier) {
flexarray_t new_flexarray(size_t member_size, size_t initial_alloc, allocator_t *alloc)
void delete_flexarray(flexarray_t array)
uint64_t flexarray_append(flexarray_t array, void *data)
void flexarray_get(flexarray_t array, void *buffer, uint64_t idx)
size_t flexarray_length(flexarray_t array)
void * memcpy(void *dest, void const *source, size_t size)
void * memset(void *dest, int c, size_t size)
size_t size
Size of the message, including metadata.
@ MT_Invalid
Invalid message, only size is valid.
enum MessageType type
Type of the message.
size_t bytes
bytes active in this page (messages not yet popped)
static void mq_alloc_page(struct MessageQueue *mq, size_t min_size)
uint64_t mq_push(uint64_t mq, struct Message *message)
size_t max_items
Maximum number of items in the queue after which mq_push will return false.
size_t bytes
Counting active-message bytes.
size_t average_message_size
Average message size, for new page allocation.
uint64_t mq_notify_teardown(mq_id_t mq, mq_notifier notifier)
struct MessageQueuePage * next
Pointer to next page.
uint64_t mq_pop(uint64_t mq, struct Message *msg)
uint64_t mq_peek(uint64_t mq, struct Message *msg)
size_t items
Counting active messages.
uint64_t mq_create(allocator_t *alloc)
allocator_t * alloc
Allocator for new pages.
struct MessageQueuePage * first_page
Pointer to first page for popping and peeking.
static const size_t MessageQueuePageItemsTarget
Target number of messages per page, muliplied by average message size for allocation size of new page...
size_t items
items active in this page (messages not yet popped)
struct MessageQueuePage * last_page
Pointer to last page for pushing.
flexarray_t notify_teardown
void init_mq(allocator_t *alloc)
size_t max_bytes
Maximum number of bytes in non-popped messsages in the queue after which mq_push will return false.
void mq_destroy(uint64_t mq)
size_t allocated
allocated bytes for the page, excluding header
size_t push_position
first free byte in page
size_t pop_position
first byte of first non-popped message
This is the implementation data for a message queue.
This is the header for a message queue page.
void(* mq_notifier)(mq_id_t mq)
void panic_message(const char *message)
void scheduler_waitable_done(enum wait_reason reason, union wait_data data, size_t max_amount)
void(* dealloc)(struct allocator *alloc, void *mem)
static bool size_t size_t uint64_t * mq
static bool struct Message * message
static uint16_t bool uint64_t * error
tpa_t * tpa_new(allocator_t *alloc, uint64_t entry_size, uint64_t page_size, tpa_t *tpa)
void * tpa_get(tpa_t *tpa, uint64_t idx)
void tpa_set(tpa_t *tpa, uint64_t idx, void *data)