starputop_message_queue.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011 William Braik, Yann Courtois, Jean-Marie Couteyen, Anthony
  4. * Roy
  5. *
  6. * StarPU is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation; either version 2.1 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * StarPU is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. *
  15. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. */
  17. #include <sys/types.h>
  18. #include <semaphore.h>
  19. #include <pthread.h>
  20. #ifndef __STARPUTOP_MESSAGE_QUEUE_H__
  21. #define __STARPUTOP_MESSAGE_QUEUE_H__
  22. typedef struct starputop_message_queue_item
  23. {
  24. char *message;
  25. struct starputop_message_queue_item* next;
  26. } starputop_message_queue_item_t;
  27. typedef struct starputop_message_queue
  28. {
  29. struct starputop_message_queue_item* head;
  30. struct starputop_message_queue_item* tail;
  31. sem_t semaphore;
  32. pthread_mutex_t mutex;
  33. } starputop_message_queue_t;
  34. starputop_message_queue_t *starputop_message_add(
  35. starputop_message_queue_t*,
  36. char*);
  37. char* starputop_message_remove(starputop_message_queue_t*);
  38. starputop_message_queue_t* starputop_message_queue_new();
  39. starputop_message_queue_t* starputop_message_queue_free(
  40. starputop_message_queue_t*);
  41. #endif