| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef SafePoint_h | 5 #ifndef SafePoint_h |
| 6 #define SafePoint_h | 6 #define SafePoint_h |
| 7 | 7 |
| 8 #include "platform/heap/ThreadState.h" | 8 #include "platform/heap/ThreadState.h" |
| 9 #include "wtf/ThreadingPrimitives.h" | 9 #include "wtf/ThreadingPrimitives.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 class SafePointScope final { | 13 class SafePointScope final { |
| 14 WTF_MAKE_NONCOPYABLE(SafePointScope); | 14 WTF_MAKE_NONCOPYABLE(SafePointScope); |
| 15 public: | 15 public: |
| 16 explicit SafePointScope(ThreadState::StackState stackState) | 16 explicit SafePointScope(ThreadState::StackState stackState, ThreadState* sta
te = ThreadState::current()) |
| 17 : m_state(ThreadState::current()) | 17 : m_state(state) |
| 18 { | 18 { |
| 19 RELEASE_ASSERT(!m_state->isAtSafePoint()); | 19 if (m_state) { |
| 20 m_state->enterSafePoint(stackState, this); | 20 RELEASE_ASSERT(!m_state->isAtSafePoint()); |
| 21 m_state->enterSafePoint(stackState, this); |
| 22 } |
| 21 } | 23 } |
| 22 | 24 |
| 23 ~SafePointScope() | 25 ~SafePointScope() |
| 24 { | 26 { |
| 25 if (m_state) | 27 if (m_state) |
| 26 m_state->leaveSafePoint(); | 28 m_state->leaveSafePoint(); |
| 27 } | 29 } |
| 28 | 30 |
| 29 private: | 31 private: |
| 30 ThreadState* m_state; | 32 ThreadState* m_state; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 volatile int m_canResume; | 123 volatile int m_canResume; |
| 122 volatile int m_unparkedThreadCount; | 124 volatile int m_unparkedThreadCount; |
| 123 Mutex m_mutex; | 125 Mutex m_mutex; |
| 124 ThreadCondition m_parked; | 126 ThreadCondition m_parked; |
| 125 ThreadCondition m_resume; | 127 ThreadCondition m_resume; |
| 126 }; | 128 }; |
| 127 | 129 |
| 128 } // namespace blink | 130 } // namespace blink |
| 129 | 131 |
| 130 #endif | 132 #endif |
| OLD | NEW |