void BandwidthManager::registerUploadDevice(UploadDevice *p)
{
- _absoluteUploadDeviceList.append(p);
- _relativeUploadDeviceList.append(p);
+ _absoluteUploadDeviceList.push_back(p);
+ _relativeUploadDeviceList.push_back(p);
QObject::connect(p, &QObject::destroyed, this, &BandwidthManager::unregisterUploadDevice);
if (usingAbsoluteUploadLimit()) {
void BandwidthManager::unregisterUploadDevice(QObject *o)
{
auto p = reinterpret_cast<UploadDevice *>(o); // note, we might already be in the ~QObject
- _absoluteUploadDeviceList.removeAll(p);
- _relativeUploadDeviceList.removeAll(p);
+ _absoluteUploadDeviceList.remove(p);
+ _relativeUploadDeviceList.remove(p);
if (p == _relativeLimitCurrentMeasuredDevice) {
_relativeLimitCurrentMeasuredDevice = nullptr;
_relativeUploadLimitProgressAtMeasuringRestart = 0;
void BandwidthManager::registerDownloadJob(GETFileJob *j)
{
- _downloadJobList.append(j);
+ _downloadJobList.push_back(j);
QObject::connect(j, &QObject::destroyed, this, &BandwidthManager::unregisterDownloadJob);
if (usingAbsoluteDownloadLimit()) {
void BandwidthManager::unregisterDownloadJob(QObject *o)
{
auto *j = reinterpret_cast<GETFileJob *>(o); // note, we might already be in the ~QObject
- _downloadJobList.removeAll(j);
+ _downloadJobList.remove(j);
if (_relativeLimitCurrentMeasuredJob == j) {
_relativeLimitCurrentMeasuredJob = nullptr;
_relativeDownloadLimitProgressAtMeasuringRestart = 0;
void BandwidthManager::relativeUploadMeasuringTimerExpired()
{
- if (!usingRelativeUploadLimit() || _relativeUploadDeviceList.count() == 0) {
+ if (!usingRelativeUploadLimit() || _relativeUploadDeviceList.size() == 0) {
// Not in this limiting mode, just wait 1 sec to continue the cycle
_relativeUploadDelayTimer.setInterval(1000);
_relativeUploadDelayTimer.start();
return;
}
- qCDebug(lcBandwidthManager) << _relativeUploadDeviceList.count() << "Starting Delay";
+ qCDebug(lcBandwidthManager) << _relativeUploadDeviceList.size() << "Starting Delay";
qint64 relativeLimitProgressMeasured = (_relativeLimitCurrentMeasuredDevice->_readWithProgress
+ _relativeLimitCurrentMeasuredDevice->_read)
_relativeUploadDelayTimer.setInterval(realWaitTimeMsec);
_relativeUploadDelayTimer.start();
- int deviceCount = _relativeUploadDeviceList.count();
+ size_t deviceCount = _relativeUploadDeviceList.size();
qint64 quotaPerDevice = relativeLimitProgressDifference * (uploadLimitPercent / 100.0) / deviceCount + 1.0;
Q_FOREACH (UploadDevice *ud, _relativeUploadDeviceList) {
ud->setBandwidthLimited(true);
return; // oh, not actually needed
}
- if (_relativeUploadDeviceList.isEmpty()) {
+ if (_relativeUploadDeviceList.empty()) {
return;
}
- qCDebug(lcBandwidthManager) << _relativeUploadDeviceList.count() << "Starting measuring";
+ qCDebug(lcBandwidthManager) << _relativeUploadDeviceList.size() << "Starting measuring";
// Take first device and then append it again (= we round robin all devices)
- _relativeLimitCurrentMeasuredDevice = _relativeUploadDeviceList.takeFirst();
- _relativeUploadDeviceList.append(_relativeLimitCurrentMeasuredDevice);
+ _relativeLimitCurrentMeasuredDevice = _relativeUploadDeviceList.front();
+ _relativeUploadDeviceList.pop_front();
+ _relativeUploadDeviceList.push_back(_relativeLimitCurrentMeasuredDevice);
_relativeUploadLimitProgressAtMeasuringRestart = (_relativeLimitCurrentMeasuredDevice->_readWithProgress
+ _relativeLimitCurrentMeasuredDevice->_read)
// for downloads:
void BandwidthManager::relativeDownloadMeasuringTimerExpired()
{
- if (!usingRelativeDownloadLimit() || _downloadJobList.count() == 0) {
+ if (!usingRelativeDownloadLimit() || _downloadJobList.size() == 0) {
// Not in this limiting mode, just wait 1 sec to continue the cycle
_relativeDownloadDelayTimer.setInterval(1000);
_relativeDownloadDelayTimer.start();
return;
}
- qCDebug(lcBandwidthManager) << _downloadJobList.count() << "Starting Delay";
+ qCDebug(lcBandwidthManager) << _downloadJobList.size() << "Starting Delay";
qint64 relativeLimitProgressMeasured = _relativeLimitCurrentMeasuredJob->currentDownloadPosition();
qint64 relativeLimitProgressDifference = relativeLimitProgressMeasured - _relativeDownloadLimitProgressAtMeasuringRestart;
_relativeDownloadDelayTimer.setInterval(realWaitTimeMsec);
_relativeDownloadDelayTimer.start();
- int jobCount = _downloadJobList.count();
+ size_t jobCount = _downloadJobList.size();
qint64 quota = relativeLimitProgressDifference * (downloadLimitPercent / 100.0);
if (quota > 20 * 1024) {
qCInfo(lcBandwidthManager) << "ADJUSTING QUOTA FROM " << quota << " TO " << quota - 20 * 1024;
return; // oh, not actually needed
}
- if (_downloadJobList.isEmpty()) {
- qCDebug(lcBandwidthManager) << _downloadJobList.count() << "No jobs?";
+ if (_downloadJobList.empty()) {
+ qCDebug(lcBandwidthManager) << _downloadJobList.size() << "No jobs?";
return;
}
- qCDebug(lcBandwidthManager) << _downloadJobList.count() << "Starting measuring";
+ qCDebug(lcBandwidthManager) << _downloadJobList.size() << "Starting measuring";
// Take first device and then append it again (= we round robin all devices)
- _relativeLimitCurrentMeasuredJob = _downloadJobList.takeFirst();
- _downloadJobList.append(_relativeLimitCurrentMeasuredJob);
+ _relativeLimitCurrentMeasuredJob = _downloadJobList.front();
+ _downloadJobList.pop_front();
+ _downloadJobList.push_back(_relativeLimitCurrentMeasuredJob);
_relativeDownloadLimitProgressAtMeasuringRestart = _relativeLimitCurrentMeasuredJob->currentDownloadPosition();
_relativeLimitCurrentMeasuredJob->setBandwidthLimited(false);
void BandwidthManager::absoluteLimitTimerExpired()
{
- if (usingAbsoluteUploadLimit() && _absoluteUploadDeviceList.count() > 0) {
- qint64 quotaPerDevice = _currentUploadLimit / qMax(1, _absoluteUploadDeviceList.count());
- qCDebug(lcBandwidthManager) << quotaPerDevice << _absoluteUploadDeviceList.count() << _currentUploadLimit;
+ if (usingAbsoluteUploadLimit() && _absoluteUploadDeviceList.size() > 0) {
+ qint64 quotaPerDevice = _currentUploadLimit / qMax((std::list<UploadDevice *>::size_type)1, _absoluteUploadDeviceList.size());
+ qCDebug(lcBandwidthManager) << quotaPerDevice << _absoluteUploadDeviceList.size() << _currentUploadLimit;
Q_FOREACH (UploadDevice *device, _absoluteUploadDeviceList) {
device->giveBandwidthQuota(quotaPerDevice);
qCDebug(lcBandwidthManager) << "Gave " << quotaPerDevice / 1024.0 << " kB to" << device;
}
}
- if (usingAbsoluteDownloadLimit() && _downloadJobList.count() > 0) {
- qint64 quotaPerJob = _currentDownloadLimit / qMax(1, _downloadJobList.count());
- qCDebug(lcBandwidthManager) << quotaPerJob << _downloadJobList.count() << _currentDownloadLimit;
+ if (usingAbsoluteDownloadLimit() && _downloadJobList.size() > 0) {
+ qint64 quotaPerJob = _currentDownloadLimit / qMax((std::list<GETFileJob *>::size_type)1, _downloadJobList.size());
+ qCDebug(lcBandwidthManager) << quotaPerJob << _downloadJobList.size() << _currentDownloadLimit;
Q_FOREACH (GETFileJob *j, _downloadJobList) {
j->giveBandwidthQuota(quotaPerJob);
qCDebug(lcBandwidthManager) << "Gave " << quotaPerJob / 1024.0 << " kB to" << j;