Mutex tidy up.
Condition variable names needn't be strings - the use was leading to valgrind
warnings.
Don't fail AssertSharedHeld when self isn't known.
Allow gtest thread chance to merge to avoid memory leak.
Make barrier test log output more human readable.
Change-Id: If1923c69a2965d933036c496dc5b1d64ec887db2
diff --git a/src/base/mutex.h b/src/base/mutex.h
index b4e0536..48c8585 100644
--- a/src/base/mutex.h
+++ b/src/base/mutex.h
@@ -258,7 +258,8 @@
// Assert the current thread has shared access to the ReaderWriterMutex.
void AssertSharedHeld(const Thread* self) {
if (kDebugLocking) {
- CHECK(IsSharedHeld(self)) << *this;
+ // TODO: we can only assert this well when self != NULL.
+ CHECK(IsSharedHeld(self) || self == NULL) << *this;
}
}
void AssertReaderHeld(const Thread* self) { AssertSharedHeld(self); }
@@ -297,7 +298,7 @@
// (Signal) or all at once (Broadcast).
class ConditionVariable {
public:
- explicit ConditionVariable(const std::string& name, Mutex& mutex);
+ explicit ConditionVariable(const char* name, Mutex& mutex);
~ConditionVariable();
void Broadcast(Thread* self);
@@ -308,7 +309,7 @@
void TimedWait(Thread* self, int64_t ms, int32_t ns) NO_THREAD_SAFETY_ANALYSIS;
private:
- std::string name_;
+ const char* const name_;
// The Mutex being used by waiters. It is an error to mix condition variables between different
// Mutexes.
Mutex& guard_;