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

Side by Side Diff: Source/platform/WebThreadSupportingGC.cpp

Issue 1274023003: compositor-worker: Get the thread to run compositor-workers from the Platform. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: . Created 5 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « Source/platform/WebThreadSupportingGC.h ('k') | no next file » | 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"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 PassOwnPtr<GCSupportForWebThread> GCSupportForWebThread::create(WebThread& threa d)
15 {
16 return adoptPtr(new GCSupportForWebThread(thread));
17 }
18
19 GCSupportForWebThread::GCSupportForWebThread(WebThread& thread)
20 : m_thread(thread)
21 {
22 m_pendingGCRunner = adoptPtr(new PendingGCRunner);
23 m_thread.addTaskObserver(m_pendingGCRunner.get());
24 ThreadState::attach();
25 OwnPtr<MessageLoopInterruptor> interruptor = adoptPtr(new MessageLoopInterru ptor(&m_thread));
26 ThreadState::current()->addInterruptor(interruptor.release());
27 }
28
29 GCSupportForWebThread::~GCSupportForWebThread()
30 {
31 m_thread.removeTaskObserver(m_pendingGCRunner.get());
32
33 ThreadState::detach();
34 m_pendingGCRunner = nullptr;
35 }
36
14 PassOwnPtr<WebThreadSupportingGC> WebThreadSupportingGC::create(const char* name ) 37 PassOwnPtr<WebThreadSupportingGC> WebThreadSupportingGC::create(const char* name )
15 { 38 {
16 #if ENABLE(ASSERT) 39 #if ENABLE(ASSERT)
17 WTF::willCreateThread(); 40 WTF::willCreateThread();
18 #endif 41 #endif
19 return adoptPtr(new WebThreadSupportingGC(name)); 42 return adoptPtr(new WebThreadSupportingGC(name));
20 } 43 }
21 44
22 WebThreadSupportingGC::WebThreadSupportingGC(const char* name) 45 WebThreadSupportingGC::WebThreadSupportingGC(const char* name)
23 : m_thread(adoptPtr(Platform::current()->createThread(name))) 46 : m_thread(adoptPtr(Platform::current()->createThread(name)))
24 { 47 {
25 } 48 }
26 49
27 WebThreadSupportingGC::~WebThreadSupportingGC() 50 WebThreadSupportingGC::~WebThreadSupportingGC()
28 { 51 {
29 if (ThreadState::current()) { 52 if (ThreadState::current()) {
30 // WebThread's destructor blocks until all the tasks are processed. 53 // WebThread's destructor blocks until all the tasks are processed.
31 SafePointScope scope(ThreadState::HeapPointersOnStack); 54 SafePointScope scope(ThreadState::HeapPointersOnStack);
32 m_thread.clear(); 55 m_thread.clear();
33 } 56 }
34 } 57 }
35 58
36 void WebThreadSupportingGC::initialize() 59 void WebThreadSupportingGC::initialize()
37 { 60 {
38 m_pendingGCRunner = adoptPtr(new PendingGCRunner); 61 m_gcSupport = GCSupportForWebThread::create(platformThread());
39 platformThread().addTaskObserver(m_pendingGCRunner.get());
40 ThreadState::attach();
41 OwnPtr<MessageLoopInterruptor> interruptor = adoptPtr(new MessageLoopInterru ptor(&platformThread()));
42 ThreadState::current()->addInterruptor(interruptor.release());
43 } 62 }
44 63
45 void WebThreadSupportingGC::shutdown() 64 void WebThreadSupportingGC::shutdown()
46 { 65 {
47 // Ensure no posted tasks will run from this point on. 66 // Ensure no posted tasks will run from this point on.
48 platformThread().removeTaskObserver(m_pendingGCRunner.get());
49 platformThread().scheduler()->shutdown(); 67 platformThread().scheduler()->shutdown();
50 68 m_gcSupport.clear();
51 ThreadState::detach();
52 m_pendingGCRunner = nullptr;
53 } 69 }
54 70
55 } // namespace blink 71 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/WebThreadSupportingGC.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698