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

Side by Side Diff: mojo/dart/embedder/monitor.h

Issue 1245243002: Move dart_debugger into tonic and use it in mojo dart controller (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « mojo/dart/embedder/dart_debugger.cc ('k') | tonic/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 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 MOJO_DART_EMBEDDER_MONITOR_H_
6 #define MOJO_DART_EMBEDDER_MONITOR_H_
7
8 #include "base/synchronization/condition_variable.h"
9 #include "base/synchronization/lock.h"
10
11 namespace mojo {
12 namespace dart {
13
14 class Monitor {
15 public:
16 Monitor() {
17 lock_ = new base::Lock();
18 condition_variable_ = new base::ConditionVariable(lock_);
19 }
20
21 ~Monitor() {
22 delete condition_variable_;
23 delete lock_;
24 }
25
26 void Enter() {
27 lock_->Acquire();
28 }
29
30 void Exit() {
31 lock_->Release();
32 }
33
34 void Notify() {
35 condition_variable_->Signal();
36 }
37
38 void Wait() {
39 condition_variable_->Wait();
40 }
41
42 private:
43 base::Lock* lock_;
44 base::ConditionVariable* condition_variable_;
45 DISALLOW_COPY_AND_ASSIGN(Monitor);
46 };
47
48 class MonitorLocker {
49 public:
50 explicit MonitorLocker(Monitor* monitor) : monitor_(monitor) {
51 CHECK(monitor_);
52 monitor_->Enter();
53 }
54
55 virtual ~MonitorLocker() {
56 monitor_->Exit();
57 }
58
59 void Wait() {
60 return monitor_->Wait();
61 }
62
63 void Notify() {
64 monitor_->Notify();
65 }
66
67 private:
68 Monitor* const monitor_;
69
70 DISALLOW_COPY_AND_ASSIGN(MonitorLocker);
71 };
72
73 } // namespace dart
74 } // namespace mojo
75
76
77 #endif // MOJO_DART_EMBEDDER_MONITOR_H_
OLDNEW
« no previous file with comments | « mojo/dart/embedder/dart_debugger.cc ('k') | tonic/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698