Defer thread creation in parsebypart example
This commit is contained in:
parent
f54b0e47a0
commit
0f9dbe0a9c
@ -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())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user