Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Destructor should be virtual.
[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, 2009-2011. The SimGrid Team.
5  * All rights reserved.                                                     */
6
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. */
9
10 #ifndef _XBT_QUEUE_H
11 #define _XBT_QUEUE_H
12
13 #include "xbt/misc.h"           /* SG_BEGIN_DECL */
14 /* #include "xbt/function_types.h" */
15
16 SG_BEGIN_DECL()
17
18 /** @addtogroup XBT_queue
19   * \brief Synchronized message exchanging queue.
20   *
21   * These is the classical producer/consumer synchronization scheme, 
22   * which all concurrent programmer recode one day or another.
23   *
24   * The good thing of this implementation is that it works seamlessly
25   * in your universe. When using one of the classical simulation
26   * interface (such as MSG), it achieves the synchronization on top
27   * of the simulator. If you use instead the real life implementation
28   * comming with GRAS, it uses the synchronization of your OS
29   * (whatever could it be). The choice is done at link time.
30   *  
31   * For performance concerns, the content of queue must be homogeneous, 
32   * just like dynars (see the \ref XBT_dynar section). Actually, queues use a 
33   * dynar to store the data, and add the synchronization on top of it. 
34   * 
35   * @{
36   */
37   /** \brief Queue data type (opaque type) */
38 typedef struct s_xbt_queue_ *xbt_queue_t;
39
40
41 XBT_PUBLIC(xbt_queue_t) xbt_queue_new(int capacity,
42                                       unsigned long elm_size);
43 XBT_PUBLIC(void) xbt_queue_free(xbt_queue_t * queue);
44
45 XBT_PUBLIC(unsigned long) xbt_queue_length(const xbt_queue_t queue);
46
47 XBT_PUBLIC(void) xbt_queue_push(xbt_queue_t queue, const void *src);
48 XBT_PUBLIC(void) xbt_queue_pop(xbt_queue_t queue, void *const dst);
49 XBT_PUBLIC(void) xbt_queue_unshift(xbt_queue_t queue, const void *src);
50 XBT_PUBLIC(void) xbt_queue_shift(xbt_queue_t queue, void *const dst);
51
52 XBT_PUBLIC(void) xbt_queue_push_timed(xbt_queue_t queue, const void *src,
53                                       double delay);
54 XBT_PUBLIC(void) xbt_queue_unshift_timed(xbt_queue_t queue,
55                                          const void *src, double delay);
56 XBT_PUBLIC(void) xbt_queue_shift_timed(xbt_queue_t queue, void *const dst,
57                                        double delay);
58 XBT_PUBLIC(void) xbt_queue_pop_timed(xbt_queue_t queue, void *const dst,
59                                      double delay);
60
61 /** @} */
62
63 SG_END_DECL()
64 #endif                          /* _XBT_QUEUE_H */