X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=runtime%2Fbase%2Fmutex.h;h=8d2cd07aeab6ffd75623d3013ee272bc8e725d32;hb=c4f72ec44660f804b595bfaf2b959f46fd2ff00d;hp=91b47ca4195d186d2c248cb1ed504d4ac197c2b4;hpb=74240819ae09e29b2753ef38f4eb4be1c2762e2e;p=android-x86%2Fart.git diff --git a/runtime/base/mutex.h b/runtime/base/mutex.h index 91b47ca41..8d2cd07ae 100644 --- a/runtime/base/mutex.h +++ b/runtime/base/mutex.h @@ -226,7 +226,8 @@ class LOCKABLE Mutex : public BaseMutex { } void AssertNotHeld(const Thread* self) { AssertNotHeldExclusive(self); } - // Id associated with exclusive owner. + // Id associated with exclusive owner. No memory ordering semantics if called from a thread other + // than the owner. uint64_t GetExclusiveOwnerTid() const; // Returns how many times this Mutex has been locked, it is better to use AssertHeld/NotHeld. @@ -239,7 +240,7 @@ class LOCKABLE Mutex : public BaseMutex { private: #if ART_USE_FUTEXES // 0 is unheld, 1 is held. - volatile int32_t state_; + AtomicInteger state_; // Exclusive owner. volatile uint64_t exclusive_owner_; // Number of waiting contenders. @@ -343,7 +344,8 @@ class LOCKABLE ReaderWriterMutex : public BaseMutex { } } - // Id associated with exclusive owner. + // Id associated with exclusive owner. No memory ordering semantics if called from a thread other + // than the owner. uint64_t GetExclusiveOwnerTid() const; virtual void Dump(std::ostream& os) const; @@ -351,12 +353,12 @@ class LOCKABLE ReaderWriterMutex : public BaseMutex { private: #if ART_USE_FUTEXES // -1 implies held exclusive, +ve shared held by state_ many owners. - volatile int32_t state_; - // Exclusive owner. + AtomicInteger state_; + // Exclusive owner. Modification guarded by this mutex. volatile uint64_t exclusive_owner_; - // Pending readers. - volatile int32_t num_pending_readers_; - // Pending writers. + // Number of contenders waiting for a reader share. + AtomicInteger num_pending_readers_; + // Number of contenders waiting to be the writer. AtomicInteger num_pending_writers_; #else pthread_rwlock_t rwlock_;