File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -128,6 +128,24 @@ template <class KeyTy, class ValueTy> struct ConcurrentMapNode {
128
128
delete Right.load (std::memory_order_acquire);
129
129
}
130
130
131
+ #ifndef NDEBUG
132
+ void dump () {
133
+ auto L = Left.load (std::memory_order_acquire);
134
+ auto R = Right.load (std::memory_order_acquire);
135
+ printf (" \" %p\" [ label = \" {<f0> %08lx | {<f1> | <f2>}}\" "
136
+ " style=\" rounded\" shape = \" record\" ];\n " , this , Key);
137
+
138
+ if (L) {
139
+ L->dump ();
140
+ printf (" \" %p\" :f1 -> \" %p\" :f0;\n " , this , L);
141
+ }
142
+ if (R) {
143
+ R->dump ();
144
+ printf (" \" %p\" :f2 -> \" %p\" :f0;\n " , this , R);
145
+ }
146
+ }
147
+ #endif
148
+
131
149
ConcurrentMapNode (const ConcurrentMapNode &) = delete ;
132
150
ConcurrentMapNode &operator =(const ConcurrentMapNode &) = delete ;
133
151
@@ -161,6 +179,20 @@ template <class KeyTy, class ValueTy> class ConcurrentMap {
161
179
// / searches the same value in a loop.
162
180
std::atomic<NodeTy *> LastSearch;
163
181
182
+ #ifndef NDEBUG
183
+ void dump () {
184
+ auto R = Root.load (std::memory_order_acquire);
185
+ printf (" digraph g {\n "
186
+ " graph [ rankdir = \" TB\" ];\n "
187
+ " node [ fontsize = \" 16\" ];\n "
188
+ " edge [ ];\n " );
189
+ if (R) {
190
+ R->dump ();
191
+ }
192
+ printf (" \n }\n " );
193
+ }
194
+ #endif
195
+
164
196
// / Search for a value by key \p Key.
165
197
// / \returns a pointer to the value or null if the value is not in the map.
166
198
ValueTy *findValueByKey (KeyTy Key) {
You can’t perform that action at this time.
0 commit comments