OLD | NEW |
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 Loading... |
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_ |
OLD | NEW |