1
0

lfmpscq.h 525 B

1234567891011121314151617181920212223
  1. #pragma once
  2. #include "queue_node.h"
  3. /* lock free unbounded multiple producer, single consumer queue */
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. typedef struct mpscq_struct_t
  8. {
  9. queue_node_t * volatile head;
  10. queue_node_t *tail;
  11. queue_node_t stub;
  12. } mpscq_t;
  13. #define MPSCQ_STATIC_INIT(self) {&self.stub, &self.stub, {0}}
  14. void mpscq_init(mpscq_t* self);
  15. int mpscq_push(mpscq_t *self, queue_node_t *n);
  16. queue_node_t *mpscq_pop(mpscq_t *self); /* returns (queue_node_t *)1 if the queue is busy */
  17. #ifdef __cplusplus
  18. }
  19. #endif