Skip to content
This repository has been archived by the owner on Aug 29, 2022. It is now read-only.

Revamped progress calculation around Task and andThen #265

Merged
merged 10 commits into from
Nov 13, 2018

Conversation

zwaldowski
Copy link
Contributor

@zwaldowski zwaldowski commented Nov 11, 2018

What's in this pull request?

Working towards #260.

Tasks created with custom progress and tasks returned from andThen with custom progress count for a unit count of 100.

Considering @piercifani's code from #260:

return startX()
    .andThen(upon: .any(), start: startY)
    .andThen(upon: .any(), start: startZ)
    .andThen(upon: .any(), start: doAA)
    .andThen(upon: .any(), start: startAB)

We have one initial Task with four calls to andThen.

At the moment the above code returns, this will now look like:

<BNRTaskRootProgress: 0x600002061220> : Parent: 0x0 / Fraction completed: 0.0000 / Completed: 0 of 5  
  <NSProgress: 0x600002061360> : Parent: 0x600002061220 / Fraction completed: 0.0000 / Completed: -1 of 0  

Then, let's say startY creates a Progress of its own. That'll look like:

<BNRTaskRootProgress: 0x600002061220> : Parent: 0x0 / Fraction completed: 0.1765 / Completed: 1 of 104  
  <NSProgress: 0x6000020645a0> : Parent: 0x600002061220 / Fraction completed: 0.1736 / Completed: 0 of 100  
    <NSProgress: 0x600002061360> : Parent: 0x6000020645a0 / Fraction completed: 0.0000 / Completed: 0 of 100  
    <NSProgress: 0x600002064640> : Parent: 0x6000020645a0 / Fraction completed: 0.1827 / Completed: 65536 of 358644  


<BNRTaskRootProgress: 0x600002061220> : Parent: 0x0 / Fraction completed: 0.6773 / Completed: 1 of 104  
  <NSProgress: 0x6000020645a0> : Parent: 0x600002061220 / Fraction completed: 0.7812 / Completed: 0 of 100  
    <NSProgress: 0x600002061360> : Parent: 0x6000020645a0 / Fraction completed: 0.0000 / Completed: 0 of 100  
    <NSProgress: 0x600002064640> : Parent: 0x6000020645a0 / Fraction completed: 0.8223 / Completed: 294912 of 358644  


<BNRTaskRootProgress: 0x600002061220> : Parent: 0x0 / Fraction completed: 0.9333 / Completed: 1 of 104  
  <NSProgress: 0x6000020645a0> : Parent: 0x600002061220 / Fraction completed: 0.9606 / Completed: 95 of 100  
    <NSProgress: 0x600002061360> : Parent: 0x6000020645a0 / Fraction completed: 0.2128 / Completed: 101816 of 478443  

Then, the last bits will trickle in:

<BNRTaskRootProgress: 0x600002061220> : Parent: 0x0 / Fraction completed: 0.9712 / Completed: 101 of 104  

Testing

Task progress reporting now has 100% test coverage.

  • Integrate "something important like URLSessionTask"-in-the-middle test, like the example above
  • Integrate "something important like URLSessionTask"-at-the-beginning test, like from Improves progress percent calculation #259 (ping @DrewFitz for a manual test against this branch).

API Changes

No public API changes, all under the hood bug fixes and cleanups.

@DrewFitz
Copy link

Did an initial test pass within my project and progress from andThening upon URLSessionTasks looks much more natural.

@piercifani
Copy link
Contributor

Much much better! 👏 👏 👏

@zwaldowski zwaldowski force-pushed the zwaldowski/and-then-what branch 10 times, most recently from 8d4050c to 282d3f3 Compare November 13, 2018 04:13
@zwaldowski zwaldowski changed the title WIP: Revamped progress calculation around Task and andThen Revamped progress calculation around Task and andThen Nov 13, 2018
@zwaldowski zwaldowski merged commit c8f8cfa into master Nov 13, 2018
@zwaldowski zwaldowski deleted the zwaldowski/and-then-what branch November 13, 2018 04:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants