Defer thread creation in parsebypart example

This commit is contained in:
Milo Yip 2016-08-29 10:17:57 +08:00
parent f54b0e47a0
commit 0f9dbe0a9c

View File

@ -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())