Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_ | 5 #ifndef BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_ |
| 6 #define BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_ | 6 #define BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <atomic> | 10 #include <atomic> |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 explicit Iterator(const PersistentMemoryAllocator* allocator); | 69 explicit Iterator(const PersistentMemoryAllocator* allocator); |
| 70 | 70 |
| 71 // As above but resuming from the |starting_after| reference. The first call | 71 // As above but resuming from the |starting_after| reference. The first call |
| 72 // to GetNext() will return the next object found after that reference. The | 72 // to GetNext() will return the next object found after that reference. The |
| 73 // reference must be to an "iterable" object; references to non-iterable | 73 // reference must be to an "iterable" object; references to non-iterable |
| 74 // objects (those that never had MakeIterable() called for them) will cause | 74 // objects (those that never had MakeIterable() called for them) will cause |
| 75 // a run-time error. | 75 // a run-time error. |
| 76 Iterator(const PersistentMemoryAllocator* allocator, | 76 Iterator(const PersistentMemoryAllocator* allocator, |
| 77 Reference starting_after); | 77 Reference starting_after); |
| 78 | 78 |
| 79 // Resets the iterator back to the beginning. | |
| 80 void Reset(); | |
|
manzagop (departed)
2016/10/04 21:02:43
Is this dangerous to introduce since we have some
bcwhite
2016/10/05 16:34:11
Each thread has its own iterator and all iterators
| |
| 81 | |
| 82 // Resets the iterator, resuming from the |starting_after| reference. | |
|
manzagop (departed)
2016/10/04 21:02:43
I'm guessing whenever you Reset(), then GetNext re
bcwhite
2016/10/05 16:34:11
Yes, the first iterable in the allocator.
| |
| 83 void Reset(Reference starting_after); | |
| 84 | |
| 85 // Returns the previously retrieved reference, or kReferenceNull if none. | |
| 86 // If constructor or reset with a starting_after location, this will return | |
| 87 // that value. | |
| 88 Reference GetLast(); | |
|
manzagop (departed)
2016/10/04 21:02:43
Add a basic test for these?
bcwhite
2016/10/05 16:34:11
Done.
| |
| 89 | |
| 79 // Gets the next iterable, storing that type in |type_return|. The actual | 90 // Gets the next iterable, storing that type in |type_return|. The actual |
| 80 // return value is a reference to the allocation inside the allocator or | 91 // return value is a reference to the allocation inside the allocator or |
| 81 // zero if there are no more. GetNext() may still be called again at a | 92 // zero if there are no more. GetNext() may still be called again at a |
| 82 // later time to retrieve any new allocations that have been added. | 93 // later time to retrieve any new allocations that have been added. |
| 83 Reference GetNext(uint32_t* type_return); | 94 Reference GetNext(uint32_t* type_return); |
| 84 | 95 |
| 85 // Similar to above but gets the next iterable of a specific |type_match|. | 96 // Similar to above but gets the next iterable of a specific |type_match|. |
| 86 // This should not be mixed with calls to GetNext() because any allocations | 97 // This should not be mixed with calls to GetNext() because any allocations |
| 87 // skipped here due to a type mis-match will never be returned by later | 98 // skipped here due to a type mis-match will never be returned by later |
| 88 // calls to GetNext() meaning it's possible to completely miss entries. | 99 // calls to GetNext() meaning it's possible to completely miss entries. |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 443 private: | 454 private: |
| 444 std::unique_ptr<MemoryMappedFile> mapped_file_; | 455 std::unique_ptr<MemoryMappedFile> mapped_file_; |
| 445 | 456 |
| 446 DISALLOW_COPY_AND_ASSIGN(FilePersistentMemoryAllocator); | 457 DISALLOW_COPY_AND_ASSIGN(FilePersistentMemoryAllocator); |
| 447 }; | 458 }; |
| 448 #endif // !defined(OS_NACL) | 459 #endif // !defined(OS_NACL) |
| 449 | 460 |
| 450 } // namespace base | 461 } // namespace base |
| 451 | 462 |
| 452 #endif // BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_ | 463 #endif // BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_ |
| OLD | NEW |