|
41 | 41 | - Expanded Future Directions
|
42 | 42 | - Expanded Alternatives Considered
|
43 | 43 | * **v6** Minor Updates:
|
44 |
| - - Changed behavior of API so that additional properties are restricted to either `Int`, `Double`, `String?`, `URL?`, or `UInt64` types instead of `any Sendable` types |
| 44 | + - 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 |
45 | 45 | - Added requirements to `ProgressManager.Property` protocol to define summarization and termination (deinit) behavior
|
46 | 46 | - Added overloads for `subscript(dynamicMember:)` in `ProgressManager.Values` to account for currently-allowed types
|
47 | 47 | - Removed `values(of:)` method
|
@@ -362,10 +362,12 @@ You can define additional properties specific to the operations you are reportin
|
362 | 362 |
|
363 | 363 | The currently allowed (Value, Summary) pairs for custom properties are:
|
364 | 364 | - (`Int`, `Int`)
|
| 365 | +- (`UInt64`, `UInt64`) |
365 | 366 | - (`Double`, `Double`)
|
366 | 367 | - (`String?`, `[String?]`)
|
367 | 368 | - (`URL?`, `[URL?]`)
|
368 | 369 | - (`UInt64`, `[UInt64]`)
|
| 370 | +- (`Duration`, `Duration`) |
369 | 371 |
|
370 | 372 | You can declare a custom additional property that has a `String?` `Value` type and `[String?]` `Summary` type as follows:
|
371 | 373 |
|
@@ -587,10 +589,12 @@ public struct Subprogress: ~Copyable, Sendable {
|
587 | 589 |
|
588 | 590 | `ProgressManager` contains a protocol `Property` that outlines the requirements for declaring a custom additional property. The currently allowed (Value, Summary) pairs are as follows:
|
589 | 591 | - (`Int`, `Int`)
|
| 592 | +- (`UInt64`, `UInt64`) |
590 | 593 | - (`Double`, `Double`)
|
591 | 594 | - (`String?`, `[String?]`)
|
592 | 595 | - (`URL?`, `[URL?]`)
|
593 | 596 | - (`UInt64`, `[UInt64]`)
|
| 597 | +- (`Duration`, `Duration`) |
594 | 598 |
|
595 | 599 | This list of allowed (Value, Summary) pairs may be expanded in the future. Based on pre-existing use cases of additional properties on `Progress`, we believe that the currently allowed (Value, Summary) pairs should suffice for most use cases.
|
596 | 600 |
|
@@ -871,6 +875,15 @@ extension ProgressManager {
|
871 | 875 | ///
|
872 | 876 | /// - Parameter key: A key path to the custom integer property type.
|
873 | 877 | public subscript<P: Property>(dynamicMember key: KeyPath<ProgressManager.Properties, P.Type>) -> Int where P.Value == Int, P.Summary == Int { get set }
|
| 878 | + |
| 879 | + /// Gets or sets custom unsigned integer properties. |
| 880 | + /// |
| 881 | + /// This subscript provides read-write access to custom progress properties where both the value |
| 882 | + /// and summary types are `UInt64`. If the property has not been set, the getter returns the |
| 883 | + /// property's default value. |
| 884 | + /// |
| 885 | + /// - Parameter key: A key path to the custom integer property type. |
| 886 | + public subscript<P: Property>(dynamicMember key: KeyPath<ProgressManager.Properties, P.Type>) -> UInt64 where P.Value == UInt64, P.Summary == UInt64 { get set } |
874 | 887 |
|
875 | 888 | /// Gets or sets custom double properties.
|
876 | 889 | ///
|
@@ -908,6 +921,15 @@ extension ProgressManager {
|
908 | 921 | /// - Parameter key: A key path to the custom UInt64 property type.
|
909 | 922 | public subscript<P: Property>(dynamicMember key: KeyPath<ProgressManager.Properties, P.Type>) -> UInt64 where P.Value == UInt64, P.Summary == [UInt64] { get set }
|
910 | 923 |
|
| 924 | + /// Gets or sets custom duration properties. |
| 925 | + /// |
| 926 | + /// This subscript provides read-write access to custom progress properties where both the value |
| 927 | + /// and summary types are `Duration`. If the property has not been set, the getter returns the |
| 928 | + /// property's default value. |
| 929 | + /// |
| 930 | + /// - Parameter key: A key path to the custom double property type. |
| 931 | + public subscript<P: Property>(dynamicMember key: KeyPath<ProgressManager.Properties, P.Type>) -> Duration where P.Value == Duration, P.Summary == Duration { get set } |
| 932 | + |
911 | 933 | /// Gets or sets the total file count property.
|
912 | 934 | /// - Parameter key: A key path to the `TotalFileCount` property type.
|
913 | 935 | public subscript(dynamicMember key: KeyPath<ProgressManager.Properties, ProgressManager.Properties.TotalFileCount.Type>) -> Int { get set }
|
@@ -950,6 +972,16 @@ extension ProgressManager {
|
950 | 972 | /// where both the value and summary types are `Int`.
|
951 | 973 | /// - Returns: An `Int` summary value for the specified property.
|
952 | 974 | public func summary<P: Property>(of property: P.Type) -> P.Summary where P.Value == Int, P.Summary == Int
|
| 975 | + |
| 976 | + /// Returns a summary for a custom unsigned integer property across the progress subtree. |
| 977 | + /// |
| 978 | + /// This method aggregates the values of a custom integer property from this progress manager |
| 979 | + /// and all its children, returning a consolidated summary value. |
| 980 | + /// |
| 981 | + /// - Parameter property: The type of the integer property to summarize. Must be a property |
| 982 | + /// where both the value and summary types are `UInt64`. |
| 983 | + /// - Returns: An `UInt64` summary value for the specified property. |
| 984 | + public func summary<P: Property>(of property: P.Type) -> P.Summary where P.Value == UInt64, P.Summary == UInt64 |
953 | 985 |
|
954 | 986 | /// Returns a summary for a custom double property across the progress subtree.
|
955 | 987 | ///
|
@@ -991,6 +1023,16 @@ extension ProgressManager {
|
991 | 1023 | /// - Returns: A `[UInt64]` summary value for the specified property.
|
992 | 1024 | public func summary<P: Property>(of property: P.Type) -> P.Summary where P.Value == UInt64, P.Summary == [UInt64]
|
993 | 1025 |
|
| 1026 | + /// Returns a summary for a custom duration property across the progress subtree. |
| 1027 | + /// |
| 1028 | + /// This method aggregates the values of a custom integer property from this progress manager |
| 1029 | + /// and all its children, returning a consolidated summary value. |
| 1030 | + /// |
| 1031 | + /// - Parameter property: The type of the integer property to summarize. Must be a property |
| 1032 | + /// where both the value and summary types are `Duration`. |
| 1033 | + /// - Returns: An `Duration` summary value for the specified property. |
| 1034 | + public func summary<P: Property>(of property: P.Type) -> P.Summary where P.Value == Duration, P.Summary == Duration |
| 1035 | + |
994 | 1036 | /// Returns the total file count across the progress subtree.
|
995 | 1037 | ///
|
996 | 1038 | /// This includes the total file count of `ProgressManager`s that are finished.
|
@@ -1092,6 +1134,16 @@ extension ProgressManager {
|
1092 | 1134 | /// where both the value and summary types are `Int`.
|
1093 | 1135 | /// - Returns: An `Int` summary value for the specified property.
|
1094 | 1136 | public func summary<P: ProgressManager.Property>(of property: P.Type) -> Int where P.Value == Int, P.Summary == Int
|
| 1137 | + |
| 1138 | + /// Returns a summary for a custom unsigned integer property across the progress subtree. |
| 1139 | + /// |
| 1140 | + /// This method aggregates the values of a custom integer property from the underlying progress manager |
| 1141 | + /// and all its children, returning a consolidated summary value. |
| 1142 | + /// |
| 1143 | + /// - Parameter property: The type of the integer property to summarize. Must be a property |
| 1144 | + /// where both the value and summary types are `UInt64`. |
| 1145 | + /// - Returns: An `UInt64` summary value for the specified property. |
| 1146 | + public func summary<P: ProgressManager.Property>(of property: P.Type) -> UInt64 where P.Value == UInt64, P.Summary == UInt64 |
1095 | 1147 |
|
1096 | 1148 | /// Returns a summary for a custom double property across the progress subtree.
|
1097 | 1149 | ///
|
@@ -1134,6 +1186,16 @@ extension ProgressManager {
|
1134 | 1186 | /// - Returns: A `[UInt64]` summary value for the specified property.
|
1135 | 1187 | public func summary<P: ProgressManager.Property>(of property: P.Type) -> [UInt64] where P.Value == UInt64, P.Summary == [UInt64]
|
1136 | 1188 |
|
| 1189 | + /// Returns a summary for a custom duration property across the progress subtree. |
| 1190 | + /// |
| 1191 | + /// This method aggregates the values of a custom integer property from the underlying progress manager |
| 1192 | + /// and all its children, returning a consolidated summary value. |
| 1193 | + /// |
| 1194 | + /// - Parameter property: The type of the integer property to summarize. Must be a property |
| 1195 | + /// where both the value and summary types are `Duration`. |
| 1196 | + /// - Returns: An `Duraton` summary value for the specified property. |
| 1197 | + public func summary<P: ProgressManager.Property>(of property: P.Type) -> Duration where P.Value == Duration, P.Summary == Duration |
| 1198 | + |
1137 | 1199 | /// Returns the total file count across the progress subtree.
|
1138 | 1200 | ///
|
1139 | 1201 | /// This includes the total file count of `ProgressManager`s that are finished.
|
@@ -1453,7 +1515,7 @@ We previously considered making `totalCount` a settable property on `ProgressMan
|
1453 | 1515 | There were discussions about representing indeterminate state in `ProgressManager` alternatively, for example, using enums. However, since `totalCount` is an optional and can be set to `nil` to represent indeterminate state, we think that this is straightforward and sufficient to represent indeterminate state for cases where developers do not know `totalCount` at the start of an operation they want to report progress for. A `ProgressManager` becomes determinate once its `totalCount` is set to an `Int`.
|
1454 | 1516 |
|
1455 | 1517 | ### Allow declared custom additional property to be any type that can be casted as `any Sendable`
|
1456 |
| -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. |
| 1518 | +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. |
1457 | 1519 |
|
1458 | 1520 | ## Acknowledgements
|
1459 | 1521 | Thanks to
|
|
0 commit comments