Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
R
rapidjson
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
rapidjson
Commits
dbe8d115
Commit
dbe8d115
authored
Feb 22, 2016
by
Milo Yip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename variable in parsebyparts
parent
24d0ebd8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
parsebyparts.cpp
example/parsebyparts/parsebyparts.cpp
+9
-9
No files found.
example/parsebyparts/parsebyparts.cpp
View file @
dbe8d115
...
...
@@ -17,7 +17,7 @@ using namespace rapidjson;
template
<
unsigned
parseFlags
=
kParseDefaultFlags
>
class
AsyncDocumentParser
{
public
:
AsyncDocumentParser
(
Document
&
d
)
:
ass
_
(
*
this
),
d_
(
d
),
parseThread_
(
&
AsyncDocumentParser
::
Parse
,
this
),
completed_
()
{}
AsyncDocumentParser
(
Document
&
d
)
:
stream
_
(
*
this
),
d_
(
d
),
parseThread_
(
&
AsyncDocumentParser
::
Parse
,
this
),
completed_
()
{}
~
AsyncDocumentParser
()
{
if
(
!
parseThread_
.
joinable
())
...
...
@@ -27,13 +27,13 @@ public:
std
::
unique_lock
<
std
::
mutex
>
lock
(
mutex_
);
// Wait until the buffer is read up (or parsing is completed)
while
(
!
ass
_
.
Empty
()
&&
!
completed_
)
while
(
!
stream
_
.
Empty
()
&&
!
completed_
)
finish_
.
wait
(
lock
);
// Automatically append '\0' as the terminator in the stream.
static
const
char
terminator
[]
=
""
;
ass
_
.
src_
=
terminator
;
ass
_
.
end_
=
terminator
+
1
;
stream
_
.
src_
=
terminator
;
stream
_
.
end_
=
terminator
+
1
;
notEmpty_
.
notify_one
();
// unblock the AsyncStringStream
}
...
...
@@ -44,7 +44,7 @@ public:
std
::
unique_lock
<
std
::
mutex
>
lock
(
mutex_
);
// Wait until the buffer is read up (or parsing is completed)
while
(
!
ass
_
.
Empty
()
&&
!
completed_
)
while
(
!
stream
_
.
Empty
()
&&
!
completed_
)
finish_
.
wait
(
lock
);
// Stop further parsing if the parsing process is completed.
...
...
@@ -52,14 +52,14 @@ public:
return
;
// Set the buffer to stream and unblock the AsyncStringStream
ass
_
.
src_
=
buffer
;
ass
_
.
end_
=
buffer
+
length
;
stream
_
.
src_
=
buffer
;
stream
_
.
end_
=
buffer
+
length
;
notEmpty_
.
notify_one
();
}
private
:
void
Parse
()
{
d_
.
ParseStream
<
parseFlags
>
(
ass
_
);
d_
.
ParseStream
<
parseFlags
>
(
stream
_
);
// The stream may not be fully read, notify finish anyway to unblock ParsePart()
std
::
unique_lock
<
std
::
mutex
>
lock
(
mutex_
);
...
...
@@ -115,7 +115,7 @@ private:
size_t
count_
;
//!< Number of characters taken so far.
};
AsyncStringStream
ass
_
;
AsyncStringStream
stream
_
;
Document
&
d_
;
std
::
thread
parseThread_
;
std
::
mutex
mutex_
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment