async_queue.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (C) 2008-2009 Nokia Corporation.
  3. *
  4. * Author: Felipe Contreras <felipe.contreras@nokia.com>
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation
  9. * version 2.1 of the License.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. *
  20. */
  21. #ifndef ASYNC_QUEUE_H
  22. #define ASYNC_QUEUE_H
  23. #include <glib.h>
  24. typedef struct AsyncQueue AsyncQueue;
  25. struct AsyncQueue {
  26. GMutex *mutex;
  27. GCond *condition;
  28. GList *head;
  29. GList *tail;
  30. guint length;
  31. gboolean enabled;
  32. };
  33. AsyncQueue *async_queue_new(void);
  34. void async_queue_free(AsyncQueue *queue);
  35. void async_queue_push(AsyncQueue *queue, gpointer data);
  36. gpointer async_queue_pop(AsyncQueue *queue);
  37. gpointer async_queue_pop_forced(AsyncQueue *queue);
  38. void async_queue_disable(AsyncQueue *queue);
  39. void async_queue_enable(AsyncQueue *queue);
  40. void async_queue_flush(AsyncQueue *queue);
  41. #endif /* ASYNC_QUEUE_H */