Browse Source

BUGFIX: Limit the number of concurrent download threads to save memory

adaptive-webui-19844
Christophe Dumez 17 years ago
parent
commit
cc4a542e9d
  1. 1
      Changelog
  2. 10
      src/downloadThread.cpp

1
Changelog

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
- FEATURE: The number of DHT nodes is displayed
- FEATURE: RSS can now be disabled from program preferences
- BUGFIX: Disable ETA calculation when ETA column is hidden
- BUGFIX: Limit the number of concurrent download threads to save memory
- COSMETIC: Transfer speed, ratio and DHT nodes are displayed in status bar
- COSMETIC: RSS Tab is now hidden as a default

10
src/downloadThread.cpp

@ -24,6 +24,8 @@ @@ -24,6 +24,8 @@
#include <QSettings>
#include <stdio.h>
#define MAX_THREADS 3
// http://curl.rtin.bz/libcurl/c/libcurl-errors.html
QString subDownloadThread::errorCodeToString(CURLcode status) {
switch(status){
@ -165,7 +167,7 @@ void downloadThread::run(){ @@ -165,7 +167,7 @@ void downloadThread::run(){
if(abort)
return;
mutex.lock();
if(url_list.size() != 0){
if(url_list.size() != 0 && subThreads.size() < MAX_THREADS){
QString url = url_list.takeFirst();
mutex.unlock();
subDownloadThread *st = new subDownloadThread(0, url);
@ -190,6 +192,9 @@ void downloadThread::propagateDownloadedFile(subDownloadThread* st, QString url, @@ -190,6 +192,9 @@ void downloadThread::propagateDownloadedFile(subDownloadThread* st, QString url,
index = downloading_list.indexOf(url);
Q_ASSERT(index != -1);
downloading_list.removeAt(index);
if(url_list.size() != 0) {
condition.wakeOne();
}
mutex.unlock();
}
@ -203,5 +208,8 @@ void downloadThread::propagateDownloadFailure(subDownloadThread* st, QString url @@ -203,5 +208,8 @@ void downloadThread::propagateDownloadFailure(subDownloadThread* st, QString url
index = downloading_list.indexOf(url);
Q_ASSERT(index != -1);
downloading_list.removeAt(index);
if(url_list.size() != 0) {
condition.wakeOne();
}
mutex.unlock();
}

Loading…
Cancel
Save