diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-01-20 13:40:20 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-01-22 12:41:23 +0000 |
commit | 7961cea6d1041e3e454dae6a1da660b453efd238 (patch) | |
tree | c0eeb4a9ff9ba32986289c1653d9608e53ccb444 /chromium/base/sampling_heap_profiler/poisson_allocation_sampler.h | |
parent | b7034d0803538058e5c9d904ef03cf5eab34f6ef (diff) |
BASELINE: Update Chromium to 78.0.3904.130
Change-Id: If185e0c0061b3437531c97c9c8c78f239352a68b
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/base/sampling_heap_profiler/poisson_allocation_sampler.h')
-rw-r--r-- | chromium/base/sampling_heap_profiler/poisson_allocation_sampler.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/chromium/base/sampling_heap_profiler/poisson_allocation_sampler.h b/chromium/base/sampling_heap_profiler/poisson_allocation_sampler.h index 3178ef7be83..6006bff19b6 100644 --- a/chromium/base/sampling_heap_profiler/poisson_allocation_sampler.h +++ b/chromium/base/sampling_heap_profiler/poisson_allocation_sampler.h @@ -12,6 +12,7 @@ #include "base/macros.h" #include "base/sampling_heap_profiler/lock_free_address_hash_set.h" #include "base/synchronization/lock.h" +#include "base/thread_annotations.h" namespace base { @@ -77,6 +78,13 @@ class BASE_EXPORT PoissonAllocationSampler { static void SetHooksInstallCallback(void (*hooks_install_callback)()); void AddSamplesObserver(SamplesObserver*); + + // Note: After an observer is removed it is still possible to receive + // a notification to that observer. This is not a problem currently as + // the only client of this interface is the base::SamplingHeapProfiler, + // which is a singleton. + // If there's a need for this functionality in the future, one might + // want to put observers notification loop under a reader-writer lock. void RemoveSamplesObserver(SamplesObserver*); void SetSamplingInterval(size_t sampling_interval); @@ -109,7 +117,12 @@ class BASE_EXPORT PoissonAllocationSampler { void BalanceAddressesHashSet(); Lock mutex_; - std::vector<SamplesObserver*> observers_; + // The |observers_| list is guarded by |mutex_|, however a copy of it + // is made before invoking the observers (to avoid performing expensive + // operations under the lock) as such the SamplesObservers themselves need + // to be thread-safe and support being invoked racily after + // RemoveSamplesObserver(). + std::vector<SamplesObserver*> observers_ GUARDED_BY(mutex_); static PoissonAllocationSampler* instance_; |