Diffusion KIO 27271405f408

SlaveBase::dispatchLoop: Fix timeout calculation

Authored by Julien Goodwin <jgoodwin@studio442.com.au> on Jan 2 2020, 1:19 PM.

Description

SlaveBase::dispatchLoop: Fix timeout calculation

Summary:
Old version of the code:

ms = qMax<int>(d->nextTimeout.elapsed() - d->nextTimeoutMsecs, 1);

... will mean the sleep is for as long as the timer has run *minus* the
intended duration, so if nextTimeoutMsecs is ever set and the timer just
started this becomes very negative, and 1ms is the result.

Inverting the subtraction:

ms = qMax<int>(d->nextTimeoutMsecs - d->nextTimeout.elapsed(), 1);

Means sleeping for the remaining time, and so far my CPU seems much
happier, with my KIO-HTTP using apps looking fine.

BUG: 392768

Reviewers: chinmoyr, davidedmundson, dfaure, broulik

Reviewed By: dfaure

Subscribers: ngraham, kde-frameworks-devel

Tags: Frameworks

Differential Revision: https://phabricator.kde.org/D26364

Details

Committed
kfunkJan 9 2020, 2:17 PM
Reviewer
dfaure
Differential Revision
D26364: SlaveBase::dispatchLoop: Fix timeout calculation
Parents
R241:40470f6cd3ee: Port setMargins
Branches
Unknown
Tags
Unknown
kfunk committed R241:27271405f408: SlaveBase::dispatchLoop: Fix timeout calculation (authored by Julien Goodwin <jgoodwin@studio442.com.au>).Jan 9 2020, 2:17 PM