Validates the internal structure of the list
| 239 | |
| 240 | /// Validates the internal structure of the list |
| 241 | bool Validate() { |
| 242 | int num_elements_found = 0; |
| 243 | std::lock_guard<LockType> lock(lock_); |
| 244 | if (head_ == nullptr) { |
| 245 | if (tail_ != nullptr) return false; |
| 246 | if (SizeLocked() != 0) return false; |
| 247 | return true; |
| 248 | } |
| 249 | |
| 250 | if (head_->prev != nullptr) return false; |
| 251 | Node* current = head_; |
| 252 | while (current != nullptr) { |
| 253 | if (current->parent_queue != this) return false; |
| 254 | ++num_elements_found; |
| 255 | Node* next = current->next; |
| 256 | if (next == nullptr) { |
| 257 | if (current != tail_) return false; |
| 258 | } else { |
| 259 | if (next->prev != current) return false; |
| 260 | } |
| 261 | current = next; |
| 262 | } |
| 263 | if (num_elements_found != SizeLocked()) return false; |
| 264 | return true; |
| 265 | } |
| 266 | |
| 267 | // Iterate over elements of queue, calling 'fn' for each element. If 'fn' returns |
| 268 | // false, terminate iteration. It is invalid to call other InternalQueue methods |
no outgoing calls