]> pd.if.org Git - liblfds/blob - liblfds/liblfds7.1.0/liblfds710/src/lfds710_queue_bounded_singleproducer_singleconsumer/lfds710_queue_bounded_singleproducer_singleconsumer_enqueue.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_enqueue.c
1 /***** includes *****/
2 #include "lfds710_queue_bounded_singleproducer_singleconsumer_internal.h"
3
4
5
6
7
8 /****************************************************************************/
9 int lfds710_queue_bss_enqueue( 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->write_index+1) & qbsss->mask ) != qbsss->read_index )
23   {
24     qbsse = qbsss->element_array + qbsss->write_index;
25
26     qbsse->key = key;
27     qbsse->value = value;
28
29     LFDS710_MISC_BARRIER_STORE;
30
31     qbsss->write_index = (qbsss->write_index + 1) & qbsss->mask;
32
33     return 1;
34   }
35
36   return 0;
37 }
38