File tree Expand file tree Collapse file tree 3 files changed +13
-4
lines changed
Sources/FoundationEssentials/ProgressManager Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -413,6 +413,7 @@ extension ProgressManager {
413
413
414
414
// MARK: Methods to Read Additional Properties of Subtree with ProgressManager as root
415
415
416
+
416
417
/// Returns a summary for a custom integer property across the progress subtree.
417
418
///
418
419
/// This method aggregates the values of a custom integer property from this progress manager
@@ -423,7 +424,9 @@ extension ProgressManager {
423
424
/// - Returns: An `Int` summary value for the specified property.
424
425
public func summary< P: Property > ( of property: P . Type ) -> P . Summary where P. Value == Int , P. Summary == Int {
425
426
if property. self == ProgressManager . Properties. TotalFileCount. self {
427
+ self . access ( keyPath: \. summarySink)
426
428
self . access ( keyPath: \. totalFileCount)
429
+ self . didSet ( keyPath: \. summarySink)
427
430
return updatedFileCount ( type: . total)
428
431
} else if property. self == ProgressManager . Properties. CompletedFileCount. self {
429
432
self . access ( keyPath: \. completedFileCount)
Original file line number Diff line number Diff line change @@ -145,6 +145,10 @@ extension ProgressManager {
145
145
state. getFileCountUpdateInfo ( type: type)
146
146
}
147
147
148
+ // for child in updateInfo.dirtyChildren.compactMap({ $0.manager }) {
149
+ // child.access(keyPath: \.summarySink)
150
+ // }
151
+
148
152
// Get updated summary for each dirty child
149
153
let updatedSummaries = updateInfo. dirtyChildren. map { ( index, child) in
150
154
State . FileCountUpdate ( index: index, updatedSummary: child. updatedFileCount ( type: type) )
@@ -337,10 +341,11 @@ extension ProgressManager {
337
341
}
338
342
339
343
internal func markChildDirty( property: ProgressManager . Properties . TotalFileCount . Type , at position: Int ) {
340
- let parents = state. withLock { state in
341
- state. markChildDirty ( property: property, at: position)
342
- }
343
- markSelfDirty ( property: property, parents: parents)
344
+ self . willSet ( keyPath: \. summarySink)
345
+ let parents = state. withLock { state in
346
+ state. markChildDirty ( property: property, at: position)
347
+ }
348
+ markSelfDirty ( property: property, parents: parents)
344
349
}
345
350
346
351
internal func markChildDirty( property: ProgressManager . Properties . CompletedFileCount . Type , at position: Int ) {
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ internal import _FoundationCollections
28
28
29
29
internal let state : Mutex < State >
30
30
internal let additionalPropertiesSink : Void
31
+ internal let summarySink : Void
31
32
32
33
/// The total units of work.
33
34
public var totalCount : Int ? {
You can’t perform that action at this time.
0 commit comments