Commit 89a2eddc authored by Jesse McKenna's avatar Jesse McKenna Committed by Commit Bot

TaskScheduler: Minor clarifications to SchedulerLock code

This is a follow-up to https://chromium-review.googlesource.com/c/chromium/src/+/1320650

Bug: 889029
Change-Id: I4dd60a56fcab509578cdfe08c999c1e34fd72375
Reviewed-on: https://chromium-review.googlesource.com/c/1331219
Commit-Queue: Jesse McKenna <jessemckenna@google.com>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607257}
parent 4ea965e8
......@@ -25,13 +25,15 @@ namespace internal {
// Default constructor, no predecessor lock.
// DCHECKs
// On Acquisition if any scheduler lock is acquired on this thread.
// Okay if a universal predecessor is acquired.
//
// SchedulerLock(const SchedulerLock* predecessor)
// Constructor that specifies an allowed predecessor for that lock.
// DCHECKs
// On Construction if |predecessor| forms a predecessor lock cycle.
// On Acquisition if the previous lock acquired on the thread is not
// |predecessor|. Okay if there was no previous lock acquired.
// either |predecessor| or a universal predecessor. Okay if there
// was no previous lock acquired.
//
// SchedulerLock(UniversalPredecessor universal_predecessor)
// Constructor for a lock that will allow the acquisition of any lock after
......
......@@ -64,12 +64,12 @@ class SafeAcquisitionTracker {
return;
// A universal predecessor may not be acquired after any other lock.
DCHECK(!lock->universal_predecessor());
DCHECK(!lock->is_universal_predecessor());
// Otherwise, make sure that the previous lock acquired is either an
// allowed predecessor for this lock or a universal predecessor.
const SchedulerLockImpl* previous_lock = acquired_locks->back();
if (previous_lock->universal_predecessor())
if (previous_lock->is_universal_predecessor())
return;
AutoLock auto_lock(allowed_predecessor_map_lock_);
......@@ -132,12 +132,12 @@ LazyInstance<SafeAcquisitionTracker>::Leaky g_safe_acquisition_tracker =
SchedulerLockImpl::SchedulerLockImpl() : SchedulerLockImpl(nullptr) {}
SchedulerLockImpl::SchedulerLockImpl(const SchedulerLockImpl* predecessor)
: universal_predecessor_(false) {
: is_universal_predecessor_(false) {
g_safe_acquisition_tracker.Get().RegisterLock(this, predecessor);
}
SchedulerLockImpl::SchedulerLockImpl(UniversalPredecessor)
: universal_predecessor_(true) {}
: is_universal_predecessor_(true) {}
SchedulerLockImpl::~SchedulerLockImpl() {
g_safe_acquisition_tracker.Get().UnregisterLock(this);
......
......@@ -37,11 +37,11 @@ class BASE_EXPORT SchedulerLockImpl {
std::unique_ptr<ConditionVariable> CreateConditionVariable();
bool universal_predecessor() const { return universal_predecessor_; }
bool is_universal_predecessor() const { return is_universal_predecessor_; }
private:
Lock lock_;
const bool universal_predecessor_;
const bool is_universal_predecessor_;
DISALLOW_COPY_AND_ASSIGN(SchedulerLockImpl);
};
......
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