Index: Source/platform/WebThreadRunner.cpp |
diff --git a/Source/platform/WebThreadRunner.cpp b/Source/platform/WebThreadRunner.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..88264dbd318d5a77fd14552d6bd3e755d0c363c8 |
--- /dev/null |
+++ b/Source/platform/WebThreadRunner.cpp |
@@ -0,0 +1,38 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+#include "platform/WebThreadRunner.h" |
+ |
+namespace blink { |
+ |
+PassOwnPtr<WebThreadRunner> WebThreadRunner::create(const char* name) |
+{ |
+ return adoptPtr(new WebThreadRunner(name)); |
+} |
+ |
+WebThreadRunner::WebThreadRunner(const char* name) |
+ : m_thread(adoptPtr(blink::Platform::current()->createThread(name))) |
+{ |
+} |
+ |
+void WebThreadRunner::attachGC() |
+{ |
+ m_pendingGCRunner = adoptPtr(new PendingGCRunner); |
+ m_messageLoopInterruptor = adoptPtr(new MessageLoopInterruptor(&platformThread())); |
+ platformThread().addTaskObserver(m_pendingGCRunner.get()); |
+ ThreadState::attach(); |
+ ThreadState::current()->addInterruptor(m_messageLoopInterruptor.get()); |
+} |
+ |
+void WebThreadRunner::detachGC() |
+{ |
+ ThreadState::current()->removeInterruptor(m_messageLoopInterruptor.get()); |
+ ThreadState::detach(); |
+ platformThread().removeTaskObserver(m_pendingGCRunner.get()); |
+ m_pendingGCRunner = nullptr; |
+ m_messageLoopInterruptor = nullptr; |
+} |
+ |
+} // namespace blink |