📬 Radikant-Queue-C

Queue Library in C

NVS

Introduction

Radikant Queue is a lightweight C protoype library that implements an efficient, thread-safe ring buffer supporting both single-threaded and multi-threaded producer-consumer patterns. Designed for handling asynchronous workloads such as BLE communication, OTA updates, and other event-driven applications with minimal overhead.

Push and Pop

FileEditViewProject
â–¶
â– 
queue_demo.c — Radikant-Queue-C
#include <radikant-queue-c.h>
 
typedef struct {
int id;
char description[32];
} task_item_t;
 
int main(){
printf("=== Single Threaded Queue Example ===\n");
Queue_t* q = queue_create(sizeof(task_item_t), 4, false);
 
for (int i = 0; i < 6; ++i) {
task_item_t item;
item.id = i;
snprintf(item.description, sizeof(item.description), "Task #%d", i);
if (queue_push(q, &item) == QUEUE_OK) {
printf("[Push] Added ID %d: %s (Size: %zu)\n", item.id, item.description, queue_size(q));
}
}
 
task_item_t out_item;
while (queue_try_pop(q, &out_item) == QUEUE_OK) {
printf("[Pop] Processed ID %d: %s\n", out_item.id, out_item.description);
}
 
queue_destroy(q);
return 0;
}
=== Single Threaded Queue Example === [Push] Added ID 0: Task #0 (Size: 1) [Push] Added ID 1: Task #1 (Size: 2) [Push] Added ID 2: Task #2 (Size: 3) [Push] Added ID 3: Task #3 (Size: 4) [Push] Added ID 4: Task #4 (Size: 5) [Push] Added ID 5: Task #5 (Size: 6) Queue currently holds 6 items. [Pop] Processed ID 0: Task #0 [Pop] Processed ID 1: Task #1 [Pop] Processed ID 2: Task #2 [Pop] Processed ID 3: Task #3 [Pop] Processed ID 4: Task #4 [Pop] Processed ID 5: Task #5