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

Defer thread creation in parsebypart example

parent f54b0e47
......@@ -21,12 +21,15 @@ public:
AsyncDocumentParser(Document& d)
: stream_(*this)
, d_(d)
, parseThread_(&AsyncDocumentParser::Parse, this)
, parseThread_()
, mutex_()
, notEmpty_()
, finish_()
, completed_()
{}
{
// Create and execute thread after all member variables are initialized.
parseThread_ = std::thread(&AsyncDocumentParser::Parse, this);
}
~AsyncDocumentParser() {
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