mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2025-02-02 05:52:31 +01:00
Limit download thread count to number of items in download queue
This commit is contained in:
parent
dea82b7991
commit
9f214d9652
@ -334,11 +334,7 @@ int Downloader::getGameDetails()
|
||||
}
|
||||
|
||||
// Create threads
|
||||
unsigned int threads = config.iThreads;
|
||||
if (gameItemQueue.size() < config.iThreads)
|
||||
{
|
||||
threads = gameItemQueue.size();
|
||||
}
|
||||
unsigned int threads = std::min(config.iThreads, static_cast<unsigned int>(gameItemQueue.size()));
|
||||
std::vector<std::thread> vThreads;
|
||||
for (unsigned int i = 0; i < threads; ++i)
|
||||
{
|
||||
@ -1006,9 +1002,14 @@ void Downloader::download()
|
||||
}
|
||||
}
|
||||
|
||||
if (!dlQueue.empty())
|
||||
{
|
||||
// Limit thread count to number of items in download queue
|
||||
unsigned int iThreads = std::min(config.iThreads, static_cast<unsigned int>(dlQueue.size()));
|
||||
|
||||
// Create download threads
|
||||
std::vector<std::thread> vThreads;
|
||||
for (unsigned int i = 0; i < config.iThreads; ++i)
|
||||
for (unsigned int i = 0; i < iThreads; ++i)
|
||||
{
|
||||
DownloadInfo dlInfo;
|
||||
dlInfo.setStatus(DLSTATUS_NOTSTARTED);
|
||||
@ -1024,6 +1025,7 @@ void Downloader::download()
|
||||
|
||||
vThreads.clear();
|
||||
vDownloadInfo.clear();
|
||||
}
|
||||
|
||||
// Create xml data for all files in the queue
|
||||
if (!createXMLQueue.empty())
|
||||
|
Loading…
x
Reference in New Issue
Block a user