diff options
author | Mathieu Chartier <mathieuc@google.com> | 2016-08-24 16:36:42 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-08-24 16:36:42 +0000 |
commit | 4d6ad96cc027778b221984b502ab2274fe258aa1 (patch) | |
tree | b19f9fa21f13c504b73b8df5d1097e66bd343668 /runtime/monitor.h | |
parent | 1f678c0b95edeeec50bdc9ab07f9220be14e86b3 (diff) | |
parent | 23da026ec7a7fae22833ed2f61a80d9f9bf7e732 (diff) | |
download | art-4d6ad96cc027778b221984b502ab2274fe258aa1.tar.gz art-4d6ad96cc027778b221984b502ab2274fe258aa1.tar.bz2 art-4d6ad96cc027778b221984b502ab2274fe258aa1.zip |
Revert "Revert "Use try lock to fix class resolution race""
am: 23da026ec7
Change-Id: Icc27f56679886cddbacdd2fcb198bdeeafdd1904
Diffstat (limited to 'runtime/monitor.h')
-rw-r--r-- | runtime/monitor.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/runtime/monitor.h b/runtime/monitor.h index 7b4b8f9467..1d829e1d68 100644 --- a/runtime/monitor.h +++ b/runtime/monitor.h @@ -62,7 +62,7 @@ class Monitor { NO_THREAD_SAFETY_ANALYSIS; // TODO: Reading lock owner without holding lock is racy. // NO_THREAD_SAFETY_ANALYSIS for mon->Lock. - static mirror::Object* MonitorEnter(Thread* thread, mirror::Object* obj) + static mirror::Object* MonitorEnter(Thread* thread, mirror::Object* obj, bool trylock) EXCLUSIVE_LOCK_FUNCTION(obj) NO_THREAD_SAFETY_ANALYSIS REQUIRES(!Roles::uninterruptible_) @@ -193,6 +193,15 @@ class Monitor { !monitor_lock_) SHARED_REQUIRES(Locks::mutator_lock_); + // Try to lock without blocking, returns true if we acquired the lock. + bool TryLock(Thread* self) + REQUIRES(!monitor_lock_) + SHARED_REQUIRES(Locks::mutator_lock_); + // Variant for already holding the monitor lock. + bool TryLockLocked(Thread* self) + REQUIRES(monitor_lock_) + SHARED_REQUIRES(Locks::mutator_lock_); + void Lock(Thread* self) REQUIRES(!monitor_lock_) SHARED_REQUIRES(Locks::mutator_lock_); |