Files
vystem/docs/shelter/std/queues.md
2026-05-27 19:34:54 +02:00

926 B

Queues

Introduction

The standard library provides various queues implementations for various objects sizes. Queue objects aren't thread safe. It is defined inside shelter/lib/include/std/queue.h and implemented in shelter/lib/src/std/queue.c.

Keyboard events queue

This queue is represented by the following object:

typedef struct {
  sh_kbd_EVENT *buffer;
  sh_uint32 capacity;
  sh_uint32 write_index;
} sh_queue_KBD_EVENT;

These queues automatically overwrite the oldest object when the caller try to push an object when the queue is full.

The API is as follows:

  • sh_queue_event_init(sh_queue_KBD_EVENT *q,sh_uint32 capacity): initialize a keyboard events queue, allocate the queue buffer
  • sh_queue_event_push(sh_queue_KBD_EVENT *q,sh_kbd_EVENT ev): push an event into the provided queue
  • sh_queue_event_destroy(sh_queue_KBD_EVENT *q): destroy the provided queue, free the queue buffer