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

Side by Side Diff: Source/platform/WebThreadSupportingGC.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.h ('k') | Source/platform/heap/SafePoint.cpp » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/WebThreadSupportingGC.h" 6 #include "platform/WebThreadSupportingGC.h"
7 7
8 #include "platform/heap/SafePoint.h" 8 #include "platform/heap/SafePoint.h"
9 #include "public/platform/WebScheduler.h" 9 #include "public/platform/WebScheduler.h"
10 #include "wtf/Threading.h" 10 #include "wtf/Threading.h"
(...skipping 18 matching lines...) Expand all
29 if (ThreadState::current()) { 29 if (ThreadState::current()) {
30 // WebThread's destructor blocks until all the tasks are processed. 30 // WebThread's destructor blocks until all the tasks are processed.
31 SafePointScope scope(ThreadState::HeapPointersOnStack); 31 SafePointScope scope(ThreadState::HeapPointersOnStack);
32 m_thread.clear(); 32 m_thread.clear();
33 } 33 }
34 } 34 }
35 35
36 void WebThreadSupportingGC::initialize() 36 void WebThreadSupportingGC::initialize()
37 { 37 {
38 m_pendingGCRunner = adoptPtr(new PendingGCRunner); 38 m_pendingGCRunner = adoptPtr(new PendingGCRunner);
39 m_messageLoopInterruptor = adoptPtr(new MessageLoopInterruptor(&platformThre ad()));
40 platformThread().addTaskObserver(m_pendingGCRunner.get()); 39 platformThread().addTaskObserver(m_pendingGCRunner.get());
41 ThreadState::attach(); 40 ThreadState::attach();
42 ThreadState::current()->addInterruptor(m_messageLoopInterruptor.get()); 41 OwnPtr<MessageLoopInterruptor> interruptor = adoptPtr(new MessageLoopInterru ptor(&platformThread()));
42 ThreadState::current()->addInterruptor(interruptor.release());
43 } 43 }
44 44
45 void WebThreadSupportingGC::shutdown() 45 void WebThreadSupportingGC::shutdown()
46 { 46 {
47 // Ensure no posted tasks will run from this point on. 47 // Ensure no posted tasks will run from this point on.
48 platformThread().removeTaskObserver(m_pendingGCRunner.get()); 48 platformThread().removeTaskObserver(m_pendingGCRunner.get());
49 platformThread().scheduler()->shutdown(); 49 platformThread().scheduler()->shutdown();
50 50
51 ThreadState::current()->removeInterruptor(m_messageLoopInterruptor.get());
52 ThreadState::detach(); 51 ThreadState::detach();
53 m_pendingGCRunner = nullptr; 52 m_pendingGCRunner = nullptr;
54 m_messageLoopInterruptor = nullptr;
55 } 53 }
56 54
57 } // namespace blink 55 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/WebThreadSupportingGC.h ('k') | Source/platform/heap/SafePoint.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698