namespace WebCore {
+static HTMLParserThread* s_sharedThread = 0;
+
HTMLParserThread::HTMLParserThread()
- : m_thread(adoptPtr(WebKit::Platform::current()->createThread("HTMLParserThread")))
{
}
{
}
+void HTMLParserThread::init()
+{
+ ASSERT(!s_sharedThread);
+ s_sharedThread = new HTMLParserThread;
+}
+
+void HTMLParserThread::shutdown()
+{
+ ASSERT(s_sharedThread);
+ delete s_sharedThread;
+ s_sharedThread = 0;
+}
+
HTMLParserThread* HTMLParserThread::shared()
{
- static HTMLParserThread* thread;
- if (!thread)
- thread = new HTMLParserThread;
- return thread;
+ return s_sharedThread;
+}
+
+blink::WebThread& HTMLParserThread::ensureThread()
+{
+ if (!m_thread)
+ m_thread = adoptPtr(blink::Platform::current()->createThread("HTMLParserThread"));
+ return *m_thread;
}
void HTMLParserThread::postTask(const Closure& closure)
{
- m_thread->postTask(new Task(closure));
+ ensureThread().postTask(new Task(closure));
}
} // namespace WebCore