diff options
author | Abseil Team <absl-team@google.com> | 2022-05-27 09:17:41 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-05-27 09:18:52 -0700 |
commit | 8cc2e34199c42543fa00baa03f1db9befcb8611f (patch) | |
tree | be9f7e4a463e8d18a3ecb9899714c79d087eeedb /absl | |
parent | 89cdaed6557dbfb8cc8fba53a9dc8baf332df8b0 (diff) |
Clarify the behaviour of `AssertHeld` and `AssertReaderHeld` when the calling thread doesn't hold the mutex.
PiperOrigin-RevId: 451410449
Change-Id: Iffd4c7463f1051474debbed256703589d96a548c
Diffstat (limited to 'absl')
-rw-r--r-- | absl/synchronization/mutex.h | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/absl/synchronization/mutex.h b/absl/synchronization/mutex.h index 9a3e438f..b69b7089 100644 --- a/absl/synchronization/mutex.h +++ b/absl/synchronization/mutex.h @@ -174,9 +174,12 @@ class ABSL_LOCKABLE Mutex { // Mutex::AssertHeld() // - // Return immediately if this thread holds the `Mutex` exclusively (in write - // mode). Otherwise, may report an error (typically by crashing with a - // diagnostic), or may return immediately. + // Require that the mutex be held exclusively (write mode) by this thread. + // + // If the mutex is not currently held by this thread, this function may report + // an error (typically by crashing with a diagnostic) or it may do nothing. + // This function is intended only as a tool to assist debugging; it doesn't + // guarantee correctness. void AssertHeld() const ABSL_ASSERT_EXCLUSIVE_LOCK(); // --------------------------------------------------------------------------- @@ -236,9 +239,13 @@ class ABSL_LOCKABLE Mutex { // Mutex::AssertReaderHeld() // - // Returns immediately if this thread holds the `Mutex` in at least shared - // mode (read mode). Otherwise, may report an error (typically by - // crashing with a diagnostic), or may return immediately. + // Require that the mutex be held at least in shared mode (read mode) by this + // thread. + // + // If the mutex is not currently held by this thread, this function may report + // an error (typically by crashing with a diagnostic) or it may do nothing. + // This function is intended only as a tool to assist debugging; it doesn't + // guarantee correctness. void AssertReaderHeld() const ABSL_ASSERT_SHARED_LOCK(); // Mutex::WriterLock() |