]> pd.if.org Git - liblfds/blob - liblfds/liblfds7.1.0/liblfds710/src/lfds710_queue_bounded_singleproducer_singleconsumer/lfds710_queue_bounded_singleproducer_singleconsumer_dequeue.c
Initial import (all versions, including the new 7.1.0)
[liblfds] / liblfds / liblfds7.1.0 / liblfds710 / src / lfds710_queue_bounded_singleproducer_singleconsumer / lfds710_queue_bounded_singleproducer_singleconsumer_dequeue.c
1 /***** includes *****/
2 #include "lfds710_queue_bounded_singleproducer_singleconsumer_internal.h"
3
4
5
6
7
8 /****************************************************************************/
9 int lfds710_queue_bss_dequeue( struct lfds710_queue_bss_state *qbsss,
10                                void **key,
11                                void **value )
12 {
13   struct lfds710_queue_bss_element
14     *qbsse;
15
16   LFDS710_PAL_ASSERT( qbsss != NULL );
17   // TRD : key can be NULL
18   // TRD : value can be NULL
19
20   LFDS710_MISC_BARRIER_LOAD;
21
22   if( qbsss->read_index != qbsss->write_index )
23   {
24     qbsse = qbsss->element_array + qbsss->read_index;
25
26     if( key != NULL )
27       *key = qbsse->key;
28
29     if( value != NULL )
30       *value = qbsse->value;
31
32     qbsss->read_index = (qbsss->read_index + 1) & qbsss->mask;
33
34     LFDS710_MISC_BARRIER_STORE;
35
36     return 1;
37   }
38
39   return 0;
40 }
41