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