lib/yajl/ParseInputStream: use InputStream::LockRead() to reduce lock duration
This commit is contained in:
parent
5913994169
commit
0211c7f7f3
@ -25,11 +25,9 @@
|
|||||||
void
|
void
|
||||||
Yajl::ParseInputStream(Handle &handle, InputStream &is)
|
Yajl::ParseInputStream(Handle &handle, InputStream &is)
|
||||||
{
|
{
|
||||||
const std::lock_guard<Mutex> protect(is.mutex);
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
unsigned char buffer[4096];
|
unsigned char buffer[4096];
|
||||||
const size_t nbytes = is.Read(buffer, sizeof(buffer));
|
const size_t nbytes = is.LockRead(buffer, sizeof(buffer));
|
||||||
if (nbytes == 0)
|
if (nbytes == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user