On Thursday 2017-05-18 11:22 +1000, Mark Hammond wrote: > I'm wondering if there are any ideas about how to solve this optimally? > Naively, it seems that the (broadest sense of the term) "platform" might be > able to help here using it's knowledge of the event-loop state - eg, a > function that indicates "are we about to starve the event loop and become > janky?", or possibly even the whole hog (ie, "please yield to the event loop > if you think now is a good time, otherwise just hand back a pre-resolved > promise").
One other option would be to use time rather than iterations as a measure of when to return. A platform API that's somewhat like this is requestIdleCallback, whose spec is at https://w3c.github.io/requestidlecallback/ -- in particular, the timeRemaining() method on the IdleDeadline object passed to the callback. See also: https://developer.mozilla.org/en-US/docs/Web/API/Window/requestIdleCallback https://developer.mozilla.org/en-US/docs/Web/API/Background_Tasks_API I'm not sure whether it works for privileged (chrome) JS, but it seems like it ought to... -David -- 𝄞 L. David Baron http://dbaron.org/ 𝄂 𝄢 Mozilla https://www.mozilla.org/ 𝄂 Before I built a wall I'd ask to know What I was walling in or walling out, And to whom I was like to give offense. - Robert Frost, Mending Wall (1914)
signature.asc
Description: PGP signature
_______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform