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

Side by Side Diff: Source/platform/heap/SafePoint.cpp

Issue 1257723002: Simplify ownership of a ThreadState's interruptors. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Switch addInterruptor() to take a PassOwnPtr<> 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 | « Source/platform/WebThreadSupportingGC.cpp ('k') | Source/platform/heap/ThreadState.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "config.h" 5 #include "config.h"
6 #include "platform/heap/SafePoint.h" 6 #include "platform/heap/SafePoint.h"
7 7
8 #include "wtf/Atomics.h" 8 #include "wtf/Atomics.h"
9 9
10 namespace blink { 10 namespace blink {
(...skipping 27 matching lines...) Expand all
38 ThreadState::AttachedThreadStateSet& threads = ThreadState::attachedThreads( ); 38 ThreadState::AttachedThreadStateSet& threads = ThreadState::attachedThreads( );
39 39
40 MutexLocker locker(m_mutex); 40 MutexLocker locker(m_mutex);
41 atomicAdd(&m_unparkedThreadCount, threads.size()); 41 atomicAdd(&m_unparkedThreadCount, threads.size());
42 releaseStore(&m_canResume, 0); 42 releaseStore(&m_canResume, 0);
43 43
44 for (ThreadState* state : threads) { 44 for (ThreadState* state : threads) {
45 if (state == current) 45 if (state == current)
46 continue; 46 continue;
47 47
48 for (ThreadState::Interruptor* interruptor : state->interruptors()) 48 for (auto& interruptor : state->interruptors())
49 interruptor->requestInterrupt(); 49 interruptor->requestInterrupt();
50 } 50 }
51 51
52 while (acquireLoad(&m_unparkedThreadCount) > 0) { 52 while (acquireLoad(&m_unparkedThreadCount) > 0) {
53 double expirationTime = currentTime() + lockingTimeout(); 53 double expirationTime = currentTime() + lockingTimeout();
54 if (!m_parked.timedWait(m_mutex, expirationTime)) { 54 if (!m_parked.timedWait(m_mutex, expirationTime)) {
55 // One of the other threads did not return to a safepoint within the maximum 55 // One of the other threads did not return to a safepoint within the maximum
56 // time we allow for threads to be parked. Abandon the GC and resume the 56 // time we allow for threads to be parked. Abandon the GC and resume the
57 // currently parked threads. 57 // currently parked threads.
58 resumeOthers(true); 58 resumeOthers(true);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // If no other thread is waiting for other threads to park then 131 // If no other thread is waiting for other threads to park then
132 // this counter can be negative: if N threads are at safe-points 132 // this counter can be negative: if N threads are at safe-points
133 // the counter will be -N. 133 // the counter will be -N.
134 if (!atomicDecrement(&m_unparkedThreadCount)) { 134 if (!atomicDecrement(&m_unparkedThreadCount)) {
135 MutexLocker locker(m_mutex); 135 MutexLocker locker(m_mutex);
136 m_parked.signal(); // Safe point reached. 136 m_parked.signal(); // Safe point reached.
137 } 137 }
138 } 138 }
139 139
140 } // namespace blink 140 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/WebThreadSupportingGC.cpp ('k') | Source/platform/heap/ThreadState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698