async_queue.h 908 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright (C) 2008-2010 Nokia Corporation
  3. *
  4. * Author: Felipe Contreras <felipe.contreras@nokia.com>
  5. *
  6. * This file may be used under the terms of the GNU Lesser General Public
  7. * License version 2.1, a copy of which is found in LICENSE included in the
  8. * packaging of this file.
  9. */
  10. #ifndef ASYNC_QUEUE_H
  11. #define ASYNC_QUEUE_H
  12. #include <glib.h>
  13. typedef struct AsyncQueue AsyncQueue;
  14. struct AsyncQueue {
  15. GMutex *mutex;
  16. GCond *condition;
  17. GList *head;
  18. GList *tail;
  19. guint length;
  20. gboolean enabled;
  21. };
  22. AsyncQueue *async_queue_new(void);
  23. void async_queue_free(AsyncQueue *queue);
  24. void async_queue_push(AsyncQueue *queue, gpointer data);
  25. gpointer async_queue_pop(AsyncQueue *queue);
  26. gpointer async_queue_pop_forced(AsyncQueue *queue);
  27. void async_queue_disable(AsyncQueue *queue);
  28. void async_queue_enable(AsyncQueue *queue);
  29. void async_queue_flush(AsyncQueue *queue);
  30. #endif /* ASYNC_QUEUE_H */