]> pd.if.org Git - liblfds/blob - liblfds/liblfds7.1.0/liblfds710/inc/liblfds710/lfds710_queue_bounded_singleproducer_singleconsumer.h
Initial import (all versions, including the new 7.1.0)
[liblfds] / liblfds / liblfds7.1.0 / liblfds710 / inc / liblfds710 / lfds710_queue_bounded_singleproducer_singleconsumer.h
1 /***** defines *****/
2 #define LFDS710_QUEUE_BSS_GET_USER_STATE_FROM_STATE( queue_bss_state )  ( (queue_bss_state).user_state )
3
4 /***** enums *****/
5 enum lfds710_queue_bss_query
6 {
7   LFDS710_QUEUE_BSS_QUERY_GET_POTENTIALLY_INACCURATE_COUNT,
8   LFDS710_QUEUE_BSS_QUERY_VALIDATE
9 };
10
11 /***** structures *****/
12 struct lfds710_queue_bss_element
13 {
14   void
15     *volatile key,
16     *volatile value;
17 };
18
19 struct lfds710_queue_bss_state
20 {
21   lfds710_pal_uint_t
22     number_elements,
23     mask;
24
25   lfds710_pal_uint_t volatile
26     read_index,
27     write_index;
28
29   struct lfds710_queue_bss_element
30     *element_array;
31
32   void
33     *user_state;
34 };
35
36 /***** public prototypes *****/
37 void lfds710_queue_bss_init_valid_on_current_logical_core( struct lfds710_queue_bss_state *qbsss, 
38                                                            struct lfds710_queue_bss_element *element_array,
39                                                            lfds710_pal_uint_t number_elements,
40                                                            void *user_state );
41   // TRD : number_elements must be a positive integer power of 2
42   // TRD : used in conjunction with the #define LFDS710_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_LOGICAL_CORE
43
44 void lfds710_queue_bss_cleanup( struct lfds710_queue_bss_state *qbsss,
45                                 void (*element_cleanup_callback)(struct lfds710_queue_bss_state *qbsss, void *key, void *value) );
46
47 int lfds710_queue_bss_enqueue( struct lfds710_queue_bss_state *qbsss,
48                                void *key,
49                                void *value );
50
51 int lfds710_queue_bss_dequeue( struct lfds710_queue_bss_state *qbsss,
52                                void **key,
53                                void **value );
54
55 void lfds710_queue_bss_query( struct lfds710_queue_bss_state *qbsss,
56                               enum lfds710_queue_bss_query query_type,
57                               void *query_input,
58                               void *query_output );
59