Skip to content

Conversation

@dfed
Copy link
Owner

@dfed dfed commented Jan 12, 2023

This PR gets each section of the README re-visiting the same ordering test to make explicit how these types solve the problem statement in the Task Ordering and Swift Concurrency section of the README.

There's still room to improve the explanation of these types, but we're making progress here.

func test_mainActor_taskOrdering() async {
var counter = 0
func testMainActorTaskOrdering() async {
actor Counter {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need a Counter type in this example but the below examples do need it. For the sake of consistency with the below additions I made this example test a dash more complicated.

This task begins execution once the above one-second sleep completes.
*/
}
Task {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Task was meant to show that we were entering an async context, but I'm realizing now that the inclusion of the Task is more confusing than not. Nothing within the Task closure changed – I just removed the Task enclosure. I did the same thing further down as well.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me. The reader can infer from the await below that we're in an asynchronous context.

}
await queue.await { }
}
```
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we'd explain better how the ActorQueue and FIFOQueue differ in the above example test, but I'm wary of trying to communicate too many ideas at once.

@dfed dfed marked this pull request as ready for review January 12, 2023 17:08
@dfed dfed requested review from bachand and omv-libs January 12, 2023 17:08
@codecov
Copy link

codecov bot commented Jan 12, 2023

Codecov Report

Merging #8 (7817047) into main (a482bb1) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##              main        #8   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            7         7           
  Lines          703       703           
=========================================
  Hits           703       703           

This task begins execution once the above one-second sleep completes.
*/
}
Task {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me. The reader can infer from the await below that we're in an asynchronous context.

XCTAssertEqual(incrementedCount, iteration) // always succeeds
}
}
await queue.await { }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe clarify with a comment that we're ensuring all tasks complete before we end the test?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix this in #9 which builds on top of this change.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XCTAssertEqual(incrementedCount, iteration) // always succeeds
}
}
await queue.await { }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we also clarify the purpose of this line.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix this in #9 which builds on top of this change.

@dfed dfed merged commit b073271 into main Feb 12, 2023
@dfed dfed deleted the dfed--readme branch February 12, 2023 20:46
dfed added a commit that referenced this pull request Feb 12, 2023
dfed added a commit that referenced this pull request Feb 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants