1 /* A (synchronized) message queue. */
2 /* Popping an empty queue is blocking, as well as pushing a full one */
4 /* Copyright (c) 2007, 2009-2011, 2013-2014. The SimGrid Team.
5 * All rights reserved. */
7 /* This program is free software; you can redistribute it and/or modify it
8 * under the terms of the license (GNU LGPL) which comes with this package. */
13 #include "xbt/misc.h" /* SG_BEGIN_DECL */
14 /* #include "xbt/function_types.h" */
18 /** @addtogroup XBT_queue
19 * \brief Synchronized message exchanging queue.
21 * These is the classical producer/consumer synchronization scheme,
22 * which all concurrent programmer recode one day or another.
24 * The synchronization of this implementation is done within the SimGrid
25 * realm, switching between SimGrid processes.
27 * For performance concerns, the content of queue must be homogeneous,
28 * just like dynars (see the \ref XBT_dynar section). Actually, queues use a
29 * dynar to store the data, and add the synchronization on top of it.
33 /** \brief Queue data type (opaque type) */
34 typedef struct s_xbt_queue_ *xbt_queue_t;
37 XBT_PUBLIC(xbt_queue_t) xbt_queue_new(int capacity,
38 unsigned long elm_size);
39 XBT_PUBLIC(void) xbt_queue_free(xbt_queue_t * queue);
41 XBT_PUBLIC(unsigned long) xbt_queue_length(const xbt_queue_t queue);
43 XBT_PUBLIC(void) xbt_queue_push(xbt_queue_t queue, const void *src);
44 XBT_PUBLIC(void) xbt_queue_pop(xbt_queue_t queue, void *const dst);
45 XBT_PUBLIC(void) xbt_queue_unshift(xbt_queue_t queue, const void *src);
46 XBT_PUBLIC(void) xbt_queue_shift(xbt_queue_t queue, void *const dst);
48 XBT_PUBLIC(void) xbt_queue_push_timed(xbt_queue_t queue, const void *src,
50 XBT_PUBLIC(void) xbt_queue_unshift_timed(xbt_queue_t queue,
51 const void *src, double delay);
52 XBT_PUBLIC(void) xbt_queue_shift_timed(xbt_queue_t queue, void *const dst,
54 XBT_PUBLIC(void) xbt_queue_pop_timed(xbt_queue_t queue, void *const dst,
60 #endif /* _XBT_QUEUE_H */