13
13
@available ( FoundationPreview 6 . 2 , * )
14
14
extension ProgressManager {
15
15
16
- /// A type that conveys task-specific information on progress.
16
+ /// A type that conveys additional task-specific information on progress.
17
17
///
18
18
/// 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`.
24
21
public protocol Property : SendableMetatype {
25
22
26
- /// The type of individual values stored in this property.
23
+ /// The type used for individual values of this property.
27
24
///
28
- /// This associated type represents the data type of individual property values
25
+ /// This associated type represents the type of property values
29
26
/// that can be set on progress managers. Must be `Sendable` and `Equatable`.
27
+ /// The currently allowed types are `Int`, `Double`, `String?`, `URL?` or `UInt64`.
30
28
associatedtype Value : Sendable , Equatable
31
29
32
30
/// The type used for aggregated summaries of this property.
33
31
///
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]`.
36
35
associatedtype Summary : Sendable , Equatable
37
36
38
37
/// A unique identifier for this property type.
@@ -54,7 +53,7 @@ extension ProgressManager {
54
53
/// The default summary value for this property type.
55
54
///
56
55
/// 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.
58
57
///
59
58
/// - Returns: The default summary value for this property type.
60
59
static var defaultSummary : Summary { get }
@@ -80,8 +79,24 @@ extension ProgressManager {
80
79
/// - Returns: A new summary that represents the combination of both input summaries.
81
80
static func merge( _ summary1: Summary , _ summary2: Summary ) -> Summary
82
81
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
85
100
}
86
101
87
102
// Namespace for properties specific to operations reported on
@@ -109,8 +124,8 @@ extension ProgressManager {
109
124
return summary1 + summary2
110
125
}
111
126
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
114
129
}
115
130
}
116
131
@@ -136,8 +151,8 @@ extension ProgressManager {
136
151
return summary1 + summary2
137
152
}
138
153
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
141
156
}
142
157
}
143
158
@@ -163,8 +178,8 @@ extension ProgressManager {
163
178
return summary1 + summary2
164
179
}
165
180
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
168
183
}
169
184
}
170
185
@@ -190,8 +205,8 @@ extension ProgressManager {
190
205
return summary1 + summary2
191
206
}
192
207
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
195
210
}
196
211
}
197
212
@@ -216,8 +231,8 @@ extension ProgressManager {
216
231
return summary1 + summary2
217
232
}
218
233
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
221
236
}
222
237
}
223
238
@@ -247,7 +262,7 @@ extension ProgressManager {
247
262
return max ( summary1, summary2)
248
263
}
249
264
250
- public static func terminate( _ parentSummary: Duration , _ childSummary : Duration ) -> Duration {
265
+ public static func terminate( _ parentSummary: Duration , _ selfSummary : Duration ) -> Duration {
251
266
return parentSummary
252
267
}
253
268
}
@@ -278,7 +293,7 @@ extension ProgressManager {
278
293
return summary1 + summary2
279
294
}
280
295
281
- public static func terminate( _ parentSummary: [ URL ? ] , _ childSummary : [ URL ? ] ) -> [ URL ? ] {
296
+ public static func terminate( _ parentSummary: [ URL ? ] , _ selfSummary : [ URL ? ] ) -> [ URL ? ] {
282
297
return parentSummary
283
298
}
284
299
}
0 commit comments