-
Notifications
You must be signed in to change notification settings - Fork 205
[Proposal] ProgressManager
Post-Review Update
#1519
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
e6af6b7
48621b6
e12818e
2e08960
6845fc6
864df54
67a5a09
3fcafe7
655e19d
6342785
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -42,11 +42,9 @@ | |||||
- Expanded Alternatives Considered | ||||||
* **v6** Minor Updates: | ||||||
- Replaced `withProperties` method with `setCounts` | ||||||
- Removed `ProgressManager.Values` struct | ||||||
- Made `ProgressManager` conform to `@dynamicMemberLookup` and moved `subscript(dynamicMember:)` methods from `ProgressManager.Values` to `ProgressManager` | ||||||
- Added `@dynamicMemberLookup` attribute to `ProgressManager` and `ProgressReporter` | ||||||
- Changed behavior of API so that additional properties are restricted to either `Int`, `Double`, `String?`, `URL?`, `UInt64` or `Duration` types instead of `any Sendable` types | ||||||
- Added overloads for `subscript(dynamicMember:)` to account for currently-allowed types | ||||||
- Added requirements to `ProgressManager.Property` protocol to define summarization and termination (deinit) behavior | ||||||
- Added requirements to `ProgressManager.Property` protocol to define summarization and cleanup (deinit) behavior | ||||||
- Replaced `total(of:)` with overloads for `summary(of:)` to account for all available types and removed `values(of:)` method | ||||||
|
||||||
## Table of Contents | ||||||
|
@@ -1434,6 +1432,43 @@ There were discussions about representing indeterminate state in `ProgressManage | |||||
### Allow declared custom additional property to be any type that can be casted as `any Sendable` | ||||||
We initially allowed the full flexibility of allowing developers to declare `ProgressManager.Property` types to be of any type, including structs. However, we realized that this has a severely negative impact on performance of the API. Thus, for now, we allow developers to only declare `ProgressManager.Property` with only certain `Value` and `Summary` types. | ||||||
|
||||||
### Introduce `withProperties` closure as an entry point to atomically mutate multiple properties | ||||||
We initially considered introducing a withProperties closure as an entry point to atomically mutate multiple properties. This approach would have used a dedicated ProgressManager.Values struct with `@dynamicMemberLookup` to provide a unified interface for modifying all properties within a single atomic operation. | ||||||
|
||||||
However, this design had several drawbacks: | ||||||
- Limited atomicity: While it allowed atomic mutation of `totalCount` and `completedCount`, it could not achieve the same atomicity for additional properties due to their differences in backing storage | ||||||
|
||||||
- Less intuitive API: The withProperties closure promoted a less natural pattern for accessing and mutating additional properties, particularly when combined with `@dynamicMemberLookup` on the nested `ProgressManager.Values` struct | ||||||
|
- Less intuitive API: The withProperties closure promoted a less natural pattern for accessing and mutating additional properties, particularly when combined with `@dynamicMemberLookup` on the nested `ProgressManager.Values` struct | |
- Less intuitive API: The `withProperties` closure promoted a less natural pattern for accessing and mutating additional properties, particularly when combined with `@dynamicMemberLookup` on the nested `ProgressManager.Values` struct |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were there discussions or feedback in the current version that was supportive of this pattern? What was the justification back then, and are they no longer valid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually the discussion that I had in mind was covered under less intuitive API, this is not needed.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify why only totalCount
and completedCount
are considered here, and why do you think that there needs to be a closure to atomically update both of them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, sounds good!
itingliu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We initially considered a simpler version of the ProgressManager.Property protocol that required only two components: | |
We initially considered a simpler version of the `ProgressManager.Property` protocol that had two requirements: |
I think we just call them requirements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll change this!
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify what "the framework" refers to? Did you mean Foundation would do the below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, but let me reword this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.