Propagator: Make sure we schedule only one job #7439

To not starve the event loop.
(There is still ~= 3 jobs running at the same time)
This commit is contained in:
Markus Goetz 2019-08-30 11:37:07 +02:00 committed by Kevin Ottens
parent 3446412d92
commit 475117dd60
No known key found for this signature in database
GPG key ID: 074BBBCB8DECC9E2
2 changed files with 6 additions and 0 deletions

View file

@ -487,6 +487,7 @@ void OwncloudPropagator::start(const SyncFileItemVector &items)
connect(_rootJob.data(), &PropagatorJob::finished, this, &OwncloudPropagator::emitFinished);
_jobScheduled = false;
scheduleNextJob();
}
@ -587,6 +588,8 @@ QString OwncloudPropagator::getFilePath(const QString &tmp_file_name) const
void OwncloudPropagator::scheduleNextJob()
{
if (_jobScheduled) return; // don't schedule more than 1
_jobScheduled = true;
QTimer::singleShot(0, this, &OwncloudPropagator::scheduleNextJobImpl);
}
@ -597,6 +600,8 @@ void OwncloudPropagator::scheduleNextJobImpl()
// Down-scaling on slow networks? https://github.com/owncloud/client/issues/3382
// Making sure we do up/down at same time? https://github.com/owncloud/client/issues/1633
_jobScheduled = false;
if (_activeJobList.count() < maximumActiveTransferJob()) {
if (_rootJob->scheduleSelfOrChild()) {
scheduleNextJob();

View file

@ -567,6 +567,7 @@ private:
AccountPtr _account;
QScopedPointer<PropagateDirectory> _rootJob;
SyncOptions _syncOptions;
bool _jobScheduled = false;
};