Commit 0f9dbe0a authored by Milo Yip's avatar Milo Yip

Defer thread creation in parsebypart example

parent f54b0e47
...@@ -21,12 +21,15 @@ public: ...@@ -21,12 +21,15 @@ public:
AsyncDocumentParser(Document& d) AsyncDocumentParser(Document& d)
: stream_(*this) : stream_(*this)
, d_(d) , d_(d)
, parseThread_(&AsyncDocumentParser::Parse, this) , parseThread_()
, mutex_() , mutex_()
, notEmpty_() , notEmpty_()
, finish_() , finish_()
, completed_() , completed_()
{} {
// Create and execute thread after all member variables are initialized.
parseThread_ = std::thread(&AsyncDocumentParser::Parse, this);
}
~AsyncDocumentParser() { ~AsyncDocumentParser() {
if (!parseThread_.joinable()) if (!parseThread_.joinable())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment