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

Side by Side Diff: runtime/vm/lockers.h

Issue 474913004: - Account for number of pending tasks in old-space collections. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_LOCKERS_H_ 5 #ifndef VM_LOCKERS_H_
6 #define VM_LOCKERS_H_ 6 #define VM_LOCKERS_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/allocation.h" 9 #include "vm/allocation.h"
10 #include "vm/globals.h" 10 #include "vm/globals.h"
11 #include "vm/isolate.h" 11 #include "vm/isolate.h"
12 #include "vm/thread.h" 12 #include "vm/thread.h"
13 13
14 namespace dart { 14 namespace dart {
15 15
16 class MutexLocker : public StackResource { 16 class MutexLocker : public ValueObject {
17 public: 17 public:
18 explicit MutexLocker(Mutex* mutex) : 18 explicit MutexLocker(Mutex* mutex) : mutex_(mutex) {
19 StackResource(Isolate::Current()),
20 mutex_(mutex) {
21 ASSERT(mutex != NULL); 19 ASSERT(mutex != NULL);
22 // TODO(iposva): Consider adding a no GC scope here. 20 // TODO(iposva): Consider adding a no GC scope here.
23 mutex_->Lock(); 21 mutex_->Lock();
24 } 22 }
25 23
26 virtual ~MutexLocker() { 24 virtual ~MutexLocker() {
27 mutex_->Unlock(); 25 mutex_->Unlock();
28 // TODO(iposva): Consider decrementing the no GC scope here. 26 // TODO(iposva): Consider decrementing the no GC scope here.
29 } 27 }
30 28
31 private: 29 private:
32 Mutex* const mutex_; 30 Mutex* const mutex_;
33 31
34 DISALLOW_COPY_AND_ASSIGN(MutexLocker); 32 DISALLOW_COPY_AND_ASSIGN(MutexLocker);
35 }; 33 };
36 34
37 35
38 class MonitorLocker : public StackResource { 36 class MonitorLocker : public ValueObject {
39 public: 37 public:
40 explicit MonitorLocker(Monitor* monitor) 38 explicit MonitorLocker(Monitor* monitor) : monitor_(monitor) {
41 : StackResource(Isolate::Current()),
42 monitor_(monitor) {
43 ASSERT(monitor != NULL); 39 ASSERT(monitor != NULL);
44 // TODO(iposva): Consider adding a no GC scope here. 40 // TODO(iposva): Consider adding a no GC scope here.
45 monitor_->Enter(); 41 monitor_->Enter();
46 } 42 }
47 43
48 virtual ~MonitorLocker() { 44 virtual ~MonitorLocker() {
49 monitor_->Exit(); 45 monitor_->Exit();
50 // TODO(iposva): Consider decrementing the no GC scope here. 46 // TODO(iposva): Consider decrementing the no GC scope here.
51 } 47 }
52 48
(...skipping 16 matching lines...) Expand all
69 private: 65 private:
70 Monitor* const monitor_; 66 Monitor* const monitor_;
71 67
72 DISALLOW_COPY_AND_ASSIGN(MonitorLocker); 68 DISALLOW_COPY_AND_ASSIGN(MonitorLocker);
73 }; 69 };
74 70
75 } // namespace dart 71 } // namespace dart
76 72
77 73
78 #endif // VM_LOCKERS_H_ 74 #endif // VM_LOCKERS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698