diff --git a/internal/base/observer_list.h b/internal/base/observer_list.h index a4d44a2f..d91333cb 100644 --- a/internal/base/observer_list.h +++ b/internal/base/observer_list.h @@ -28,6 +28,11 @@ class ObserverList { using const_iterator = typename absl::flat_hash_set::const_iterator; + ~ObserverList() ABSL_LOCKS_EXCLUDED(mutex_) { + MutexLock lock(&mutex_); + observers_.clear(); + } + void AddObserver(ObserverType* observer) ABSL_LOCKS_EXCLUDED(mutex_) { MutexLock lock(&mutex_); observers_.insert(observer);