Skip to content

Commit 2fbd586

Browse files
committed
Minimize use of blocking .get()'s in test_http_server
1 parent 5f75ec9 commit 2fbd586

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

Release/tests/functional/http/utilities/test_http_server.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -520,23 +520,24 @@ class _test_http_server
520520
for (auto it = result.headers().begin(); it != result.headers().end(); ++it)
521521
tr->m_headers[it->first] = it->second;
522522

523-
tr->m_body = result.extract_vector().get();
524-
525-
{
526-
pplx::extensibility::scoped_critical_section_t lock(m_lock);
527-
m_responding_requests[tr->m_request_id] = result;
528-
}
523+
result.extract_vector().then([this,tr,result](const std::vector<unsigned char>& v) {
524+
tr->m_body = v;
525+
{
526+
pplx::extensibility::scoped_critical_section_t lock(m_lock);
527+
m_responding_requests[tr->m_request_id] = result;
528+
}
529529

530-
while (!m_cancel)
531-
{
532-
pplx::extensibility::scoped_critical_section_t lock(m_lock);
533-
if (m_requests.size() > 0)
530+
while (!m_cancel)
534531
{
535-
m_requests[0].set(tr);
536-
m_requests.erase(m_requests.begin());
537-
return;
532+
pplx::extensibility::scoped_critical_section_t lock(m_lock);
533+
if (m_requests.size() > 0)
534+
{
535+
m_requests[0].set(tr);
536+
m_requests.erase(m_requests.begin());
537+
return;
538+
}
538539
}
539-
}
540+
});
540541
});
541542
}
542543

0 commit comments

Comments
 (0)