diff options
Diffstat (limited to 'shared/queue.h')
| -rw-r--r-- | shared/queue.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/shared/queue.h b/shared/queue.h new file mode 100644 index 0000000..8a6655c --- /dev/null +++ b/shared/queue.h @@ -0,0 +1,20 @@ +#pragma once + +#include <pthread.h> +#include <stdint.h> +#include <stdbool.h> + +#define QUEUE_SIZE 256 +#define PACKET_MAX_SIZE 2048 + +typedef struct { + uint8_t data[QUEUE_SIZE][PACKET_MAX_SIZE]; + int size[QUEUE_SIZE]; + int head; + int tail; + pthread_mutex_t lock; +} PacketQueue; + +void QueueInit(PacketQueue *q); +void QueuePush(PacketQueue *q, void *data, int size); +bool QueuePop(PacketQueue *q, void *data, int *size); |