lib/yajl/ParseInputStream: use InputStream::LockRead() to reduce lock duration

This commit is contained in:
Max Kellermann 2018-01-11 20:10:38 +01:00
parent 5913994169
commit 0211c7f7f3

View File

@ -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;