tlds
Transactional Operations for Linked Data Structures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
transskip.h
Go to the documentation of this file.
1 #ifndef __TRANSSKIP_H__
2 #define __TRANSSKIP_H__
3 
4 
5 #include <cstdint>
6 #include "common/assert.h"
7 #include "common/allocator.h"
8 
9 typedef unsigned long setkey_t;
10 typedef void *setval_t;
11 
12 
13 #ifdef __SET_IMPLEMENTATION__
14 
15 /*************************************
16  * INTERNAL DEFINITIONS
17  */
18 
19 /* Fine for 2^NUM_LEVELS nodes. */
20 #define NUM_LEVELS 20
21 
22 
23 /* Internal key values with special meanings. */
24 #define INVALID_FIELD (0) /* Uninitialised field value. */
25 #define SENTINEL_KEYMIN ( 1UL) /* Key value of first dummy node. */
26 #define SENTINEL_KEYMAX (~0UL) /* Key value of last dummy node. */
27 
28 
29 /*
30  * Used internally be set access functions, so that callers can use
31  * key values 0 and 1, without knowing these have special meanings.
32  */
33 #define CALLER_TO_INTERNAL_KEY(_k) ((_k) + 2)
34 #define INTERNAL_TO_CALLER_KEY(_k) ((_k) - 2)
35 
36 
37 /*
38  * SUPPORT FOR WEAK ORDERING OF MEMORY ACCESSES
39  */
40 
41 #ifdef WEAK_MEM_ORDER
42 
43 /* Read field @_f into variable @_x. */
44 #define READ_FIELD(_x,_f) \
45 do { \
46  (_x) = (_f); \
47  if ( (_x) == INVALID_FIELD ) { RMB(); (_x) = (_f); } \
48  assert((_x) != INVALID_FIELD); \
49 } while ( 0 )
50 
51 #else
52 
53 /* Read field @_f into variable @_x. */
54 #define READ_FIELD(_x,_f) ((_x) = (_f))
55 
56 #endif
57 
58 #endif /* __SET_IMPLEMENTATION__ */
59 
60 /*************************************
61  * PUBLIC DEFINITIONS
62  */
63 
64 /*************************************
65  * Transaction Definitions
66  */
67 
68 struct Operator
69 {
70  uint8_t type;
71  uint32_t key;
72 };
73 
74 struct Desc
75 {
76  static size_t SizeOf(uint8_t size)
77  {
78  return sizeof(uint8_t) + sizeof(uint8_t) + sizeof(Operator) * size;
79  }
80 
81  volatile uint8_t status;
82  uint8_t size;
84 };
85 
86 struct NodeDesc
87 {
88  NodeDesc(Desc* _desc, uint8_t _opid)
89  : desc(_desc), opid(_opid){}
90 
92  uint8_t opid;
93 };
94 
95 struct node_t
96 {
97  int level;
98 #define LEVEL_MASK 0x0ff
99 #define READY_FOR_FREE 0x100
102 
104 
106 };
107 
109 {
112 
115 };
116 
117 
118 /*
119  * Key range accepted by set functions.
120  * We lose three values (conveniently at top end of key space).
121  * - Known invalid value to which all fields are initialised.
122  * - Sentinel key values for up to two dummy nodes.
123  */
124 #define KEY_MIN ( 0U)
125 #define KEY_MAX ((~0U) - 3)
126 
127 
128 void init_transskip_subsystem(void);
129 void destroy_transskip_subsystem(void);
130 
131 
132 bool execute_ops(trans_skip* l, Desc* desc);
133 
134 /*
135  * Allocate an empty set.
136  */
137 trans_skip *transskip_alloc(Allocator<Desc>* _descAllocator, Allocator<NodeDesc>* _nodeDescAllocator);
138 
140 
141 #endif /* __SET_H__ */
node_t * tail
Definition: transskip.h:113
Definition: transskip.h:95
Definition: transskip.h:108
NodeDesc(Desc *_desc, uint8_t _opid)
Definition: transskip.h:88
setkey_t k
Definition: transskip.h:100
node_t * next[1]
Definition: transskip.h:105
bool execute_ops(trans_skip *l, Desc *desc)
Definition: transskip.cc:909
Operator ops[]
Definition: transskip.h:83
Definition: transskip.h:68
Definition: defs.h:133
volatile uint8_t status
Definition: transskip.h:81
Desc * desc
Definition: transskip.h:91
unsigned long setkey_t
Definition: transskip.h:9
uint32_t key
Definition: transskip.h:71
setval_t v
Definition: transskip.h:101
void * setval_t
Definition: lockfreeskip.h:6
void transskip_free(trans_skip *l)
Definition: transskip.cc:929
void init_transskip_subsystem(void)
Definition: transskip.cc:796
Allocator< Desc > * descAllocator
Definition: transskip.h:110
node_t head
Definition: transskip.h:114
void destroy_transskip_subsystem(void)
Definition: transskip.cc:809
Definition: transskip.h:74
void * setval_t
Definition: transskip.h:10
Definition: transskip.h:86
uint8_t size
Definition: transskip.h:82
uint8_t opid
Definition: transskip.h:92
NodeDesc * nodeDesc
Definition: transskip.h:103
int level
Definition: transskip.h:97
uint8_t type
Definition: transskip.h:70
trans_skip * transskip_alloc(Allocator< Desc > *_descAllocator, Allocator< NodeDesc > *_nodeDescAllocator)
Definition: transskip.cc:331
Allocator< NodeDesc > * nodeDescAllocator
Definition: transskip.h:111
static size_t SizeOf(uint8_t size)
Definition: transskip.h:76