libfuncs is collection of code (list, queue, circular buffer, io, logging, etc.). https://georgi.unixsol.org/programs/libfuncs/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

queue.h 755B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * IPTV.bg Media Proxy
  3. * Request queue header file
  4. *
  5. * Copyright (C) 2006 Unix Solutions Ltd.
  6. * Written by Luben Karavelov (luben@unixsol.org)
  7. *
  8. */
  9. #ifndef QUEUE_H
  10. # define QUEUE_H
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. #include <pthread.h>
  15. typedef struct QNODE {
  16. struct QNODE *next;
  17. void *data;
  18. } QNODE;
  19. typedef struct QUEUE {
  20. QNODE *head;
  21. QNODE *tail;
  22. pthread_mutex_t *mutex; // queue's mutex.
  23. pthread_cond_t *cond; // queue's condition variable.
  24. int items; // number of messages in queue
  25. } QUEUE;
  26. QUEUE *queue_new ();
  27. void queue_free (QUEUE **q);
  28. void queue_add (QUEUE *q, void *data);
  29. void *queue_get (QUEUE *q);
  30. void *queue_get_nowait (QUEUE *q);
  31. void queue_wakeup (QUEUE *q);
  32. #ifdef __cplusplus
  33. }
  34. #endif
  35. #endif