Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: base/task_scheduler/scheduler_lock.h

Issue 1685423002: Task Scheduler. (Closed) Base URL: https://luckyluke-private.googlesource.com/src@a_master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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/synchronization/lock.h"
13
14 namespace base {
15 namespace task_scheduler {
16
17 // A regular lock with simple deadlock correctness checking.
18 // This lock is used throughout the scheduler, and when DCHECK_IS_ON(), tracks
19 // all of the available locks to make sure that any locks are acquired in
20 // an expected order.
21 class BASE_EXPORT SchedulerLock {
22 public:
23 SchedulerLock();
24 explicit SchedulerLock(const SchedulerLock* predecessor);
25 ~SchedulerLock();
26
27 void Acquire();
28 void Release();
29
30 Lock* RawLockForConditionVariable();
31
32 private:
33 Lock lock;
34
35 DISALLOW_COPY_AND_ASSIGN(SchedulerLock);
36 };
37
38 class AutoSchedulerLock {
39 public:
40 explicit AutoSchedulerLock(SchedulerLock& lock) : lock_(lock) {
41 lock_.Acquire();
42 }
43
44 ~AutoSchedulerLock() {
45 lock_.Release();
46 }
47
48 private:
49 SchedulerLock& lock_;
50 DISALLOW_COPY_AND_ASSIGN(AutoSchedulerLock);
51 };
52
53 } // namespace task_scheduler
54 } // namespace base
55
56 #endif // BASE_TASK_SCHEDULER_SCHEDULER_LOCK_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698