init: Document the locking strategy used in class PropWaiterState
Let the compiler verify that lock_ is held when any of the data members
are accessed.
Bug: 266255006
Change-Id: I71b341815d84ab530627d934ad4d4681b652b9d8
Signed-off-by: Bart Van Assche <bvanassche@google.com>
diff --git a/init/init.cpp b/init/init.cpp
index 9312f26..c965fe6 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -212,16 +212,16 @@
}
private:
- void ResetWaitForPropLocked() {
+ void ResetWaitForPropLocked() EXCLUSIVE_LOCKS_REQUIRED(lock_) {
wait_prop_name_.clear();
wait_prop_value_.clear();
waiting_for_prop_.reset();
}
std::mutex lock_;
- std::unique_ptr<Timer> waiting_for_prop_{nullptr};
- std::string wait_prop_name_;
- std::string wait_prop_value_;
+ GUARDED_BY(lock_) std::unique_ptr<Timer> waiting_for_prop_{nullptr};
+ GUARDED_BY(lock_) std::string wait_prop_name_;
+ GUARDED_BY(lock_) std::string wait_prop_value_;
} prop_waiter_state;