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
@@ -3,6 +3,7 @@
|
||||
#include <NetworkInterface.hpp>
|
||||
#include <NetworkTypes.hpp>
|
||||
#include <Types.hpp>
|
||||
#include <Void/Async/ThreadPool.hpp>
|
||||
#include <Void/Data/Json.hpp>
|
||||
#include <Void/Data/Reflect.hpp>
|
||||
#include <atomic>
|
||||
@@ -125,6 +126,10 @@ namespace Echoion::Core
|
||||
Api::RetryConfig retryConfig_;
|
||||
mutable std::mutex mutex_;
|
||||
std::atomic<bool> initialized_{false};
|
||||
|
||||
// Worker pool backing the *Async / requestBatch fan-outs, replacing
|
||||
// a per-call std::async OS-thread spawn with bounded thread reuse.
|
||||
Void::Concurrency::ThreadPool pool_;
|
||||
};
|
||||
|
||||
} // namespace Echoion::Core
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <NetworkTypes.hpp>
|
||||
#include <TrackTypes.hpp>
|
||||
#include <Types.hpp>
|
||||
#include <Void/Async/ThreadPool.hpp>
|
||||
#include <YouTubeTypes.hpp>
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
@@ -151,6 +152,10 @@ namespace Echoion::Core
|
||||
std::unique_ptr<YtDlpManager> ytDlpManager_;
|
||||
std::unique_ptr<UrlShortener> urlShortener_;
|
||||
|
||||
// Worker pool backing the parallel API/resolution fan-outs. Bounds
|
||||
// thread reuse instead of spawning an OS thread per std::async call.
|
||||
Void::Concurrency::ThreadPool pool_;
|
||||
|
||||
std::atomic<bool> initialized_{false};
|
||||
mutable std::mutex mutex_;
|
||||
|
||||
|
||||
Reference in new issue
Block a user