Phase C: back parallel fan-outs with Void ThreadPool
Replace the per-call std::async OS-thread spawns in the blocking fan-out/collect paths with a bounded Void::Concurrency::ThreadPool member, giving thread reuse instead of an unbounded thread per request: - YouTubeClient: getVideoInfoAsync, getPlaylistAsync, and the two playlist resolution batches now submit to pool_. The std::future<T>/.get() join semantics are unchanged, so control flow is identical. - NetworkClient: getAsync/postAsync/requestAsync (and thus requestBatch) submit to pool_. populateShortenedUrls is deliberately left on std::async — it relies on wide parallelism under a tight 5s budget, which a bounded pool would throttle. Build green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
51f1651c18
commit
5775c522eb
4 files changed
+27
-21
No files matched your search
+6
-11
@@ -163,28 +163,23 @@ namespace Echoion::Core
|
||||
NetworkClient::getAsync(std::string_view url,
|
||||
const std::vector<Api::HttpHeader>& headers)
|
||||
{
|
||||
return std::async(std::launch::async,
|
||||
[this, u = std::string(url), headers] {
|
||||
return get(u, headers);
|
||||
});
|
||||
return pool_.submit([this, u = std::string(url), headers] {
|
||||
return get(u, headers);
|
||||
});
|
||||
}
|
||||
|
||||
std::future<Api::Result<Api::HttpResponse>>
|
||||
NetworkClient::postAsync(std::string_view url, std::string_view body,
|
||||
const std::vector<Api::HttpHeader>& headers)
|
||||
{
|
||||
return std::async(std::launch::async,
|
||||
[this, u = std::string(url),
|
||||
b = std::string(body), headers] {
|
||||
return post(u, b, headers);
|
||||
});
|
||||
return pool_.submit([this, u = std::string(url), b = std::string(body),
|
||||
headers] { return post(u, b, headers); });
|
||||
}
|
||||
|
||||
std::future<Api::Result<Api::HttpResponse>>
|
||||
NetworkClient::requestAsync(const Api::HttpRequest& req)
|
||||
{
|
||||
return std::async(std::launch::async,
|
||||
[this, req] { return request(req); });
|
||||
return pool_.submit([this, req] { return request(req); });
|
||||
}
|
||||
|
||||
std::vector<Api::Result<Api::HttpResponse>>
|
||||
|
||||
Reference in new issue
Block a user