Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef BASE_TASK_SCHEDULER_SCHEDULER_LOCK_H | |
| 6 #define BASE_TASK_SCHEDULER_SCHEDULER_LOCK_H | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/base_export.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/synchronization/condition_variable.h" | |
| 14 #include "base/synchronization/lock.h" | |
| 15 #include "base/task_scheduler/scheduler_lock_impl.h" | |
| 16 | |
| 17 namespace base { | |
| 18 namespace internal { | |
| 19 | |
|
gab
2016/02/18 16:58:06
Add a meta comment here on how this class should b
robliao
2016/02/18 21:59:36
Done, except for the loops part. The unit tests ac
| |
| 20 #if DCHECK_IS_ON() | |
| 21 class SchedulerLock : public SchedulerLockImpl { | |
| 22 public: | |
| 23 SchedulerLock() = default; | |
| 24 explicit SchedulerLock(const SchedulerLock* predecessor) | |
| 25 : SchedulerLockImpl(predecessor) {} | |
| 26 }; | |
| 27 #else | |
|
gab
2016/02/18 16:58:06
#else // DCHECK_IS_ON()
robliao
2016/02/18 21:59:36
Done.
| |
| 28 class SchedulerLock : public Lock { | |
| 29 public: | |
| 30 SchedulerLock() = default; | |
| 31 explicit SchedulerLock(const SchedulerLock*) {} | |
| 32 | |
| 33 // Functionally equivalent to SchedulerLockImpl::CreateConditionVariable. | |
| 34 scoped_ptr<ConditionVariable> CreateConditionVariable() { | |
| 35 return scoped_ptr<ConditionVariable>(new ConditionVariable(this)); | |
| 36 } | |
| 37 }; | |
| 38 #endif | |
|
gab
2016/02/18 16:58:06
#endif // DCHECK_IS_ON()
robliao
2016/02/18 21:59:36
Done.
| |
| 39 | |
| 40 class AutoSchedulerLock { | |
| 41 public: | |
| 42 explicit AutoSchedulerLock(SchedulerLock& lock) : lock_(lock) { | |
| 43 lock_.Acquire(); | |
| 44 } | |
| 45 | |
| 46 ~AutoSchedulerLock() { | |
| 47 lock_.Release(); | |
|
gab
2016/02/18 16:58:06
Add
lock_.AssertAcquired();
above.
(to match Au
robliao
2016/02/18 21:59:36
Done.
| |
| 48 } | |
| 49 | |
| 50 private: | |
| 51 SchedulerLock& lock_; | |
| 52 DISALLOW_COPY_AND_ASSIGN(AutoSchedulerLock); | |
|
gab
2016/02/18 16:58:06
Chromium style is typically to have an empty line
robliao
2016/02/18 21:59:36
Done.
| |
| 53 }; | |
| 54 | |
| 55 } // namespace internal | |
| 56 } // namespace base | |
| 57 | |
| 58 #endif // BASE_TASK_SCHEDULER_SCHEDULER_LOCK_H | |
| OLD | NEW |