1313@available ( FoundationPreview 6 . 2 , * )
1414extension ProgressManager {
1515
16- /// A type that conveys task-specific information on progress.
16+ /// A type that conveys additional task-specific information on progress.
1717 ///
1818 /// The `Property` protocol defines custom properties that can be associated with progress tracking.
19- /// These properties allow you to store and aggregate additional information alongside the standard
20- /// progress metrics like completion counts and file counts.
21- ///
22- /// Properties use a key-value system where the key uniquely identifies the property type,
23- /// and values can be aggregated across progress manager hierarchies through reduction and merging operations.
19+ /// These properties allow you to store and aggregate additional information alongside the
20+ /// standard progress metrics such as `totalCount` and `completedCount`.
2421 public protocol Property : SendableMetatype {
2522
26- /// The type of individual values stored in this property.
23+ /// The type used for individual values of this property.
2724 ///
28- /// This associated type represents the data type of individual property values
25+ /// This associated type represents the type of property values
2926 /// that can be set on progress managers. Must be `Sendable` and `Equatable`.
27+ /// The currently allowed types are `Int`, `Double`, `String?`, `URL?` or `UInt64`.
3028 associatedtype Value : Sendable , Equatable
3129
3230 /// The type used for aggregated summaries of this property.
3331 ///
34- /// This associated type represents the data type used when summarizing property values
35- /// across multiple progress managers in a hierarchy. Must be `Sendable` and `Equatable`.
32+ /// This associated type represents the type used when summarizing property values
33+ /// across multiple progress managers in a subtree.
34+ /// The currently allowed types are `Int`, `Double`, `[String?]`, `[URL?]` or `[UInt64]`.
3635 associatedtype Summary : Sendable , Equatable
3736
3837 /// A unique identifier for this property type.
@@ -54,7 +53,7 @@ extension ProgressManager {
5453 /// The default summary value for this property type.
5554 ///
5655 /// This value is used as the initial summary when no property values have been
57- /// aggregated yet, or as a fallback when summarization fails .
56+ /// aggregated yet.
5857 ///
5958 /// - Returns: The default summary value for this property type.
6059 static var defaultSummary : Summary { get }
@@ -80,8 +79,24 @@ extension ProgressManager {
8079 /// - Returns: A new summary that represents the combination of both input summaries.
8180 static func merge( _ summary1: Summary , _ summary2: Summary ) -> Summary
8281
83- /// Determines the behavior for handling childSummary when the child is deinitialized.
84- static func terminate( _ parentSummary: Summary , _ childSummary: Summary ) -> Summary
82+ /// Determines how to handle summary data when a progress manager is deinitialized.
83+ ///
84+ /// This method is used when a progress manager in the hierarchy is being
85+ /// deinitialized and its accumulated summary needs to be processed in relation to
86+ /// its parent's summary. The behavior can vary depending on the property type:
87+ ///
88+ /// - For additive properties (like file counts, byte counts): The self summary
89+ /// is typically added to the parent summary to preserve the accumulated progress.
90+ /// - For max-based properties (like estimated time remaining): The parent summary
91+ /// is typically preserved as it represents an existing estimate.
92+ /// - For collection-based properties (like file URLs): The self summary may be
93+ /// discarded to avoid accumulating stale references.
94+ ///
95+ /// - Parameters:
96+ /// - parentSummary: The current summary value of the parent progress manager.
97+ /// - selfSummary: The final summary value from the progress manager being deinitialized.
98+ /// - Returns: The updated summary that replaces the parent's current summary.
99+ static func terminate( _ parentSummary: Summary , _ selfSummary: Summary ) -> Summary
85100 }
86101
87102 // Namespace for properties specific to operations reported on
@@ -109,8 +124,8 @@ extension ProgressManager {
109124 return summary1 + summary2
110125 }
111126
112- public static func terminate( _ parentSummary: Int , _ childSummary : Int ) -> Int {
113- return parentSummary + childSummary
127+ public static func terminate( _ parentSummary: Int , _ selfSummary : Int ) -> Int {
128+ return parentSummary + selfSummary
114129 }
115130 }
116131
@@ -136,8 +151,8 @@ extension ProgressManager {
136151 return summary1 + summary2
137152 }
138153
139- public static func terminate( _ parentSummary: Int , _ childSummary : Int ) -> Int {
140- return parentSummary + childSummary
154+ public static func terminate( _ parentSummary: Int , _ selfSummary : Int ) -> Int {
155+ return parentSummary + selfSummary
141156 }
142157 }
143158
@@ -163,8 +178,8 @@ extension ProgressManager {
163178 return summary1 + summary2
164179 }
165180
166- public static func terminate( _ parentSummary: UInt64 , _ childSummary : UInt64 ) -> UInt64 {
167- return parentSummary + childSummary
181+ public static func terminate( _ parentSummary: UInt64 , _ selfSummary : UInt64 ) -> UInt64 {
182+ return parentSummary + selfSummary
168183 }
169184 }
170185
@@ -190,8 +205,8 @@ extension ProgressManager {
190205 return summary1 + summary2
191206 }
192207
193- public static func terminate( _ parentSummary: UInt64 , _ childSummary : UInt64 ) -> UInt64 {
194- return parentSummary + childSummary
208+ public static func terminate( _ parentSummary: UInt64 , _ selfSummary : UInt64 ) -> UInt64 {
209+ return parentSummary + selfSummary
195210 }
196211 }
197212
@@ -216,8 +231,8 @@ extension ProgressManager {
216231 return summary1 + summary2
217232 }
218233
219- public static func terminate( _ parentSummary: [ UInt64 ] , _ childSummary : [ UInt64 ] ) -> [ UInt64 ] {
220- return parentSummary + childSummary
234+ public static func terminate( _ parentSummary: [ UInt64 ] , _ selfSummary : [ UInt64 ] ) -> [ UInt64 ] {
235+ return parentSummary + selfSummary
221236 }
222237 }
223238
@@ -247,7 +262,7 @@ extension ProgressManager {
247262 return max ( summary1, summary2)
248263 }
249264
250- public static func terminate( _ parentSummary: Duration , _ childSummary : Duration ) -> Duration {
265+ public static func terminate( _ parentSummary: Duration , _ selfSummary : Duration ) -> Duration {
251266 return parentSummary
252267 }
253268 }
@@ -278,7 +293,7 @@ extension ProgressManager {
278293 return summary1 + summary2
279294 }
280295
281- public static func terminate( _ parentSummary: [ URL ? ] , _ childSummary : [ URL ? ] ) -> [ URL ? ] {
296+ public static func terminate( _ parentSummary: [ URL ? ] , _ selfSummary : [ URL ? ] ) -> [ URL ? ] {
282297 return parentSummary
283298 }
284299 }
0 commit comments