Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
aede6cc0276d1e356690571630fb3e855d631cae
[simgrid.git] / include / xbt / queue.h
1 /* A (synchronized) message queue.                                          */
2 /* Popping an empty queue is blocking, as well as pushing a full one        */
3
4 /* Copyright (c) 2007 Martin Quinson. All rights reserved.                  */
5
6 /* This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. */
8
9 #ifndef _XBT_QUEUE_H
10 #define _XBT_QUEUE_H
11
12 #include "xbt/misc.h"           /* SG_BEGIN_DECL */
13 /* #include "xbt/function_types.h" */
14
15 SG_BEGIN_DECL()
16
17 /** @addtogroup XBT_queue
18   * @brief Synchronized message exchanging queue.
19   *
20   * These is the classical producer/consumer synchronization scheme, which all concurrent programmer recode one day or another.
21   *  
22   * For performance concerns, the content of queue must be homogeneous, 
23   * just like dynars (see the \ref XBT_dynar section). Indeed, queues use a 
24   * dynar to store the data, and add the synchronization on top of it. 
25   * 
26   * @{
27   */
28   /** \brief Queue data type (opaque type) */
29      typedef struct s_xbt_queue_ *xbt_queue_t;
30
31
32 XBT_PUBLIC(xbt_queue_t) xbt_queue_new(int capacity, unsigned long elm_size);
33 XBT_PUBLIC(void) xbt_queue_free(xbt_queue_t * queue);
34
35 XBT_PUBLIC(unsigned long) xbt_queue_length(const xbt_queue_t queue);
36
37 XBT_PUBLIC(void) xbt_queue_push(xbt_queue_t queue, const void *src);
38 XBT_PUBLIC(void) xbt_queue_pop(xbt_queue_t queue, void *const dst);
39 XBT_PUBLIC(void) xbt_queue_unshift(xbt_queue_t queue, const void *src);
40 XBT_PUBLIC(void) xbt_queue_shift(xbt_queue_t queue, void *const dst);
41
42 XBT_PUBLIC(void) xbt_queue_push_timed(xbt_queue_t queue, const void *src,
43                                       double delay);
44 XBT_PUBLIC(void) xbt_queue_unshift_timed(xbt_queue_t queue, const void *src,
45                                          double delay);
46 XBT_PUBLIC(void) xbt_queue_shift_timed(xbt_queue_t queue, void *const dst,
47                                        double delay);
48 XBT_PUBLIC(void) xbt_queue_pop_timed(xbt_queue_t queue, void *const dst,
49                                      double delay);
50
51 /** @} */
52
53 SG_END_DECL()
54 #endif /* _XBT_QUEUE_H */