Commit 8cc2e341 by Abseil Team Committed by Copybara-Service

Clarify the behaviour of `AssertHeld` and `AssertReaderHeld` when the calling…

Clarify the behaviour of `AssertHeld` and `AssertReaderHeld` when the calling thread doesn't hold the mutex.

PiperOrigin-RevId: 451410449
Change-Id: Iffd4c7463f1051474debbed256703589d96a548c
parent 89cdaed6
...@@ -174,9 +174,12 @@ class ABSL_LOCKABLE Mutex { ...@@ -174,9 +174,12 @@ class ABSL_LOCKABLE Mutex {
// Mutex::AssertHeld() // Mutex::AssertHeld()
// //
// Return immediately if this thread holds the `Mutex` exclusively (in write // Require that the mutex be held exclusively (write mode) by this thread.
// mode). Otherwise, may report an error (typically by crashing with a //
// diagnostic), or may return immediately. // 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(); void AssertHeld() const ABSL_ASSERT_EXCLUSIVE_LOCK();
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -236,9 +239,13 @@ class ABSL_LOCKABLE Mutex { ...@@ -236,9 +239,13 @@ class ABSL_LOCKABLE Mutex {
// Mutex::AssertReaderHeld() // Mutex::AssertReaderHeld()
// //
// Returns immediately if this thread holds the `Mutex` in at least shared // Require that the mutex be held at least in shared mode (read mode) by this
// mode (read mode). Otherwise, may report an error (typically by // thread.
// crashing with a diagnostic), or may return immediately. //
// 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(); void AssertReaderHeld() const ABSL_ASSERT_SHARED_LOCK();
// Mutex::WriterLock() // Mutex::WriterLock()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment