mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
Fixed the data race in ObserverList
PiperOrigin-RevId: 528638464
This commit is contained in:
committed by
Copybara-Service
parent
8741eb6c71
commit
9ea2c9fd8e
@@ -28,6 +28,11 @@ class ObserverList {
|
||||
using const_iterator =
|
||||
typename absl::flat_hash_set<ObserverType*>::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);
|
||||
|
||||
Reference in New Issue
Block a user