summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/rapidjson/example/parsebyparts/parsebyparts.cpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/rapidjson/example/parsebyparts/parsebyparts.cpp')
-rw-r--r--3rdparty/rapidjson/example/parsebyparts/parsebyparts.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/3rdparty/rapidjson/example/parsebyparts/parsebyparts.cpp b/3rdparty/rapidjson/example/parsebyparts/parsebyparts.cpp
index 57eed005dea..ff735394ec9 100644
--- a/3rdparty/rapidjson/example/parsebyparts/parsebyparts.cpp
+++ b/3rdparty/rapidjson/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())
@@ -140,7 +143,7 @@ int main() {
AsyncDocumentParser<> parser(d);
const char json1[] = " { \"hello\" : \"world\", \"t\" : tr";
- //const char json1[] = " { \"hello\" : \"world\", \"t\" : trX"; // Fot test parsing error
+ //const char json1[] = " { \"hello\" : \"world\", \"t\" : trX"; // For test parsing error
const char json2[] = "ue, \"f\" : false, \"n\": null, \"i\":123, \"pi\": 3.14";
const char json3[] = "16, \"a\":[1, 2, 3, 4] } ";