Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/miloyip/rapidjson.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilo Yip <miloyip@gmail.com>2016-08-29 05:17:57 +0300
committerMilo Yip <miloyip@gmail.com>2016-08-29 05:17:57 +0300
commit0f9dbe0a9c78b6a8163e47a4b5e1c5df7a3360b9 (patch)
treea6bb9a7d450e2df8c883356993732c65f1e25180 /example
parentf54b0e47a08782a6131cc3d60f94d038fa6e0a51 (diff)
Defer thread creation in parsebypart example
Diffstat (limited to 'example')
-rw-r--r--example/parsebyparts/parsebyparts.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/example/parsebyparts/parsebyparts.cpp b/example/parsebyparts/parsebyparts.cpp
index 57eed005..a377efd4 100644
--- a/example/parsebyparts/parsebyparts.cpp
+++ b/example/parsebyparts/parsebyparts.cpp
@@ -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())