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

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

Issue 1717803002: Add a SafepointMutexLocker class so that it is possible to have scopes inside the MutexLocker which… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: self-code-review 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
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"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 void NotifyAll() { 64 void NotifyAll() {
65 monitor_->NotifyAll(); 65 monitor_->NotifyAll();
66 } 66 }
67 67
68 private: 68 private:
69 Monitor* const monitor_; 69 Monitor* const monitor_;
70 70
71 DISALLOW_COPY_AND_ASSIGN(MonitorLocker); 71 DISALLOW_COPY_AND_ASSIGN(MonitorLocker);
72 }; 72 };
73 73
74
75 // SafepointMutexLocker objects are used in code where the locks are
76 // more coarse grained and a safepoint operation could be potentially
77 // triggered while holding this lock. This ensures that other threads
78 // which try to acquire the same lock will be marked as being at a
79 // safepoint when they are blocked.
80 class SafepointMutexLocker : public ValueObject {
81 public:
82 explicit SafepointMutexLocker(Mutex* mutex);
83 virtual ~SafepointMutexLocker() {
84 mutex_->Unlock();
85 }
86
87 private:
88 Mutex* const mutex_;
89
90 DISALLOW_COPY_AND_ASSIGN(SafepointMutexLocker);
91 };
92
74 } // namespace dart 93 } // namespace dart
75 94
76 95
77 #endif // VM_LOCKERS_H_ 96 #endif // VM_LOCKERS_H_
OLDNEW
« runtime/vm/isolate.h ('K') | « runtime/vm/isolate.cc ('k') | runtime/vm/lockers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698