@@ -56,11 +56,16 @@ impl BlockList {
56
56
// }
57
57
#[ cfg( feature = "ms_block_list_sanity" ) ]
58
58
fn verify_block_list ( & self , sanity_list : & mut Vec < Block > ) {
59
- if !sanity_list. iter ( ) . map ( |b| * b) . eq ( BlockListIterator { cursor : self . first } ) {
59
+ if !sanity_list
60
+ . iter ( )
61
+ . map ( |b| * b)
62
+ . eq ( BlockListIterator { cursor : self . first } )
63
+ {
60
64
eprintln ! ( "Sanity block list: {:?}" , sanity_list) ;
61
65
eprintln ! ( "First {:?}" , sanity_list. get( 0 ) ) ;
62
66
eprintln ! ( "Actual block list: {:?}" , self ) ;
63
67
eprintln ! ( "First {:?}" , self . first) ;
68
+ eprintln ! ( "Block list {:?}" , self as * const _) ;
64
69
panic ! ( "Incorrect block list" ) ;
65
70
}
66
71
}
@@ -81,6 +86,7 @@ impl BlockList {
81
86
82
87
/// Remove a block from the list
83
88
pub fn remove ( & mut self , block : Block ) {
89
+ trace ! ( "Blocklist {:?}: Remove {:?}" , self as * const _, block) ;
84
90
match ( block. load_prev_block ( ) , block. load_next_block ( ) ) {
85
91
( None , None ) => {
86
92
self . first = None ;
@@ -89,12 +95,14 @@ impl BlockList {
89
95
( None , Some ( next) ) => {
90
96
next. clear_prev_block ( ) ;
91
97
self . first = Some ( next) ;
92
- next. store_block_list ( self ) ;
98
+ // next.store_block_list(self);
99
+ debug_assert_eq ! ( next. load_block_list( ) , self as * mut _) ;
93
100
}
94
101
( Some ( prev) , None ) => {
95
102
prev. clear_next_block ( ) ;
96
103
self . last = Some ( prev) ;
97
- prev. store_block_list ( self ) ;
104
+ // prev.store_block_list(self);
105
+ debug_assert_eq ! ( prev. load_block_list( ) , self as * mut _) ;
98
106
}
99
107
( Some ( prev) , Some ( next) ) => {
100
108
prev. store_next_block ( next) ;
@@ -105,7 +113,11 @@ impl BlockList {
105
113
#[ cfg( feature = "ms_block_list_sanity" ) ]
106
114
{
107
115
let mut sanity_list = self . sanity_list . lock ( ) . unwrap ( ) ;
108
- if let Some ( ( index, _) ) = sanity_list. iter ( ) . enumerate ( ) . find ( |& ( _, & val) | val == block) {
116
+ if let Some ( ( index, _) ) = sanity_list
117
+ . iter ( )
118
+ . enumerate ( )
119
+ . find ( |& ( _, & val) | val == block)
120
+ {
109
121
sanity_list. remove ( index) ;
110
122
} else {
111
123
panic ! ( "Cannot find {:?} in the block list" , block) ;
@@ -144,11 +156,13 @@ impl BlockList {
144
156
assert_eq ! ( sanity_ret, ret) ;
145
157
}
146
158
159
+ trace ! ( "Blocklist {:?}: Pop = {:?}" , self as * const _, ret) ;
147
160
ret
148
161
}
149
162
150
163
/// Push block to the front of the list
151
164
pub fn push ( & mut self , block : Block ) {
165
+ trace ! ( "Blocklist {:?}: Push {:?}" , self as * const _, block) ;
152
166
if self . is_empty ( ) {
153
167
block. clear_next_block ( ) ;
154
168
block. clear_prev_block ( ) ;
@@ -173,6 +187,11 @@ impl BlockList {
173
187
174
188
/// Moves all the blocks of `other` into `self`, leaving `other` empty.
175
189
pub fn append ( & mut self , other : & mut BlockList ) {
190
+ trace ! (
191
+ "Blocklist {:?}: Append Blocklist {:?}" ,
192
+ self as * const _,
193
+ other as * const _
194
+ ) ;
176
195
#[ cfg( feature = "ms_block_list_sanity" ) ]
177
196
{
178
197
// Check before merging
@@ -226,6 +245,7 @@ impl BlockList {
226
245
227
246
/// Remove all blocks
228
247
fn reset ( & mut self ) {
248
+ trace ! ( "Blocklist {:?}: Reset" , self as * const _) ;
229
249
self . first = None ;
230
250
self . last = None ;
231
251
@@ -252,10 +272,12 @@ impl BlockList {
252
272
. compare_exchange ( false , true , Ordering :: SeqCst , Ordering :: SeqCst )
253
273
. is_ok ( ) ;
254
274
}
275
+ trace ! ( "Blocklist {:?}: locked" , self as * const _) ;
255
276
}
256
277
257
278
/// Unlock list. See the comments on the lock method.
258
279
pub fn unlock ( & mut self ) {
280
+ trace ! ( "Blocklist {:?}: unlock" , self as * const _) ;
259
281
self . lock . store ( false , Ordering :: SeqCst ) ;
260
282
}
261
283
0 commit comments