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