Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to reduce dl impact on slow computers (web) #1513

Merged
merged 2 commits into from Sep 28, 2018
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Prev

Use a update wire wrapper instead

  • Loading branch information
Chocobozzz committed Sep 27, 2018
commit 5b7c5eebf41c9e1e1fe8e9e1d4a6ad06e93e7430
@@ -1138,7 +1138,17 @@ class Torrent extends EventEmitter {
const ite = randomIterate(this.wires)
let wire
while ((wire = ite())) {
this._updateWire(wire)
this._updateWireWrapper(wire)
}
}

_updateWireWrapper (wire) {
const self = this

if (typeof window !== 'undefined' && typeof window.requestIdleCallback === 'function') {
window.requestIdleCallback(function () { self._updateWire(wire) })
} else {
self._updateWire(wire)
}
}

@@ -1156,11 +1166,7 @@ class Torrent extends EventEmitter {
if (wire.requests.length >= minOutstandingRequests) return
const maxOutstandingRequests = getBlockPipelineLength(wire, PIPELINE_MAX_DURATION)

if (typeof window !== 'undefined' && typeof window.requestIdleCallback === 'function') {
window.requestIdleCallback(function () { trySelectWire(false) || trySelectWire(true) })
} else {
trySelectWire(false) || trySelectWire(true)
}
trySelectWire(false) || trySelectWire(true)

function genPieceFilterFunc (start, end, tried, rank) {
return i => i >= start && i <= end && !(i in tried) && wire.peerPieces.get(i) && (!rank || rank(i))
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.