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 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 // offset into the segment; this allows combining allocations into a | 786 // offset into the segment; this allows combining allocations into a |
787 // single persistent segment to reduce overhead and means an "all or | 787 // single persistent segment to reduce overhead and means an "all or |
788 // nothing" request. Note that |size| is always the total memory size | 788 // nothing" request. Note that |size| is always the total memory size |
789 // and |offset| is just indicating the start of a block within it. If | 789 // and |offset| is just indicating the start of a block within it. If |
790 // |make_iterable| was true, the allocation will made iterable when it | 790 // |make_iterable| was true, the allocation will made iterable when it |
791 // is created; already existing allocations are not changed. | 791 // is created; already existing allocations are not changed. |
792 // | 792 // |
793 // Once allocated, a reference to the segment will be stored at |ref|. | 793 // Once allocated, a reference to the segment will be stored at |ref|. |
794 // This shared location must be initialized to zero (0); it is checked | 794 // This shared location must be initialized to zero (0); it is checked |
795 // with every Get() request to see if the allocation has already been | 795 // with every Get() request to see if the allocation has already been |
796 // done. | 796 // done. If reading |ref| outside of this object, be sure to do an |
| 797 // "acquire" load. Don't write to it -- leave that to this object. |
797 // | 798 // |
798 // For convenience, methods taking both Atomic32 and std::atomic<Reference> | 799 // For convenience, methods taking both Atomic32 and std::atomic<Reference> |
799 // are defined. | 800 // are defined. |
800 DelayedPersistentAllocation(PersistentMemoryAllocator* allocator, | 801 DelayedPersistentAllocation(PersistentMemoryAllocator* allocator, |
801 subtle::Atomic32* ref, | 802 subtle::Atomic32* ref, |
802 uint32_t type, | 803 uint32_t type, |
803 size_t size, | 804 size_t size, |
804 bool make_iterable); | 805 bool make_iterable); |
805 DelayedPersistentAllocation(PersistentMemoryAllocator* allocator, | 806 DelayedPersistentAllocation(PersistentMemoryAllocator* allocator, |
806 subtle::Atomic32* ref, | 807 subtle::Atomic32* ref, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 // share the same pointer then an allocation on one will amount to an | 860 // share the same pointer then an allocation on one will amount to an |
860 // allocation for all. | 861 // allocation for all. |
861 volatile std::atomic<Reference>* const reference_; | 862 volatile std::atomic<Reference>* const reference_; |
862 | 863 |
863 // No DISALLOW_COPY_AND_ASSIGN as it's okay to copy/move these objects. | 864 // No DISALLOW_COPY_AND_ASSIGN as it's okay to copy/move these objects. |
864 }; | 865 }; |
865 | 866 |
866 } // namespace base | 867 } // namespace base |
867 | 868 |
868 #endif // BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_ | 869 #endif // BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_ |
OLD | NEW |