@@ -363,34 +363,19 @@ extension ProgressManager {
363
363
}
364
364
365
365
internal func getUpdatedThroughput( ) -> [ UInt64 ] {
366
+ // Collect information from state
367
+ let updateInfo = state. withLock { state in
368
+ state. getThroughputUpdateInfo ( )
369
+ }
370
+
371
+ // Get updated summary for each dirty child
372
+ let updatedSummaries = updateInfo. dirtyChildren. map { ( index, child) in
373
+ State . ThroughputUpdate ( index: index, updatedSummary: child. getUpdatedThroughput ( ) )
374
+ }
375
+
376
+ // Consolidate updated values
366
377
return state. withLock { state in
367
- // Get self's throughput as part of summary
368
- var value = ProgressManager . Properties. Throughput. defaultSummary
369
- ProgressManager . Properties. Throughput. reduce ( into: & value, value: state. throughput)
370
-
371
- guard !state. children. isEmpty else {
372
- return value
373
- }
374
-
375
- for (idx, childState) in state. children. enumerated ( ) {
376
- if childState. throughput. isDirty {
377
- // Update dirty path
378
- if let child = childState. child {
379
- let updatedSummary = child. getUpdatedThroughput ( )
380
- let newThroughputState = PropertyStateThroughput ( value: updatedSummary, isDirty: false )
381
- state. children [ idx] . throughput = newThroughputState
382
- value = ProgressManager . Properties. Throughput. merge ( value, updatedSummary)
383
- }
384
- } else {
385
- if let _ = childState. child {
386
- // Merge non-dirty, updated value
387
- value = ProgressManager . Properties. Throughput. merge ( value, childState. throughput. value)
388
- } else {
389
- value = ProgressManager . Properties. Throughput. finalSummary ( value, childState. throughput. value)
390
- }
391
- }
392
- }
393
- return value
378
+ state. getUpdatedThroughput ( updateInfo, updatedSummaries)
394
379
}
395
380
}
396
381
@@ -518,88 +503,77 @@ extension ProgressManager {
518
503
519
504
internal func markChildDirty( property: MetatypeWrapper < Int , Int > , at position: Int ) {
520
505
let parents = state. withLock { state in
521
- state. children [ position] . childPropertiesInt [ property] ? . isDirty = true
522
- return state. parents
506
+ state. markChildDirty ( property: property, at: position)
523
507
}
524
508
markSelfDirty ( property: property, parents: parents)
525
509
}
526
510
527
511
internal func markChildDirty( property: MetatypeWrapper < Double , Double > , at position: Int ) {
528
512
let parents = state. withLock { state in
529
- state. children [ position] . childPropertiesDouble [ property] ? . isDirty = true
530
- return state. parents
513
+ state. markChildDirty ( property: property, at: position)
531
514
}
532
515
markSelfDirty ( property: property, parents: parents)
533
516
}
534
517
535
518
internal func markChildDirty( property: MetatypeWrapper < String ? , [ String ? ] > , at position: Int ) {
536
519
let parents = state. withLock { state in
537
- state. children [ position] . childPropertiesString [ property] ? . isDirty = true
538
- return state. parents
520
+ state. markChildDirty ( property: property, at: position)
539
521
}
540
522
markSelfDirty ( property: property, parents: parents)
541
523
}
542
524
543
525
internal func markChildDirty( property: MetatypeWrapper < URL ? , [ URL ? ] > , at position: Int ) {
544
526
let parents = state. withLock { state in
545
- state. children [ position] . childPropertiesURL [ property] ? . isDirty = true
546
- return state. parents
527
+ state. markChildDirty ( property: property, at: position)
547
528
}
548
529
markSelfDirty ( property: property, parents: parents)
549
530
}
550
531
551
532
internal func markChildDirty( property: MetatypeWrapper < UInt64 , [ UInt64 ] > , at position: Int ) {
552
533
let parents = state. withLock { state in
553
- state. children [ position] . childPropertiesUInt64 [ property] ? . isDirty = true
554
- return state. parents
534
+ state. markChildDirty ( property: property, at: position)
555
535
}
556
536
markSelfDirty ( property: property, parents: parents)
557
537
}
558
538
559
539
internal func markChildDirty( property: ProgressManager . Properties . TotalFileCount . Type , at position: Int ) {
560
540
let parents = state. withLock { state in
561
- state. children [ position] . totalFileCount. isDirty = true
562
- return state. parents
541
+ state. markChildDirty ( property: property, at: position)
563
542
}
564
543
markSelfDirty ( property: property, parents: parents)
565
544
}
566
545
567
546
internal func markChildDirty( property: ProgressManager . Properties . CompletedFileCount . Type , at position: Int ) {
568
547
let parents = state. withLock { state in
569
- state. children [ position] . completedFileCount. isDirty = true
570
- return state. parents
548
+ state. markChildDirty ( property: property, at: position)
571
549
}
572
550
markSelfDirty ( property: property, parents: parents)
573
551
}
574
552
575
553
internal func markChildDirty( property: ProgressManager . Properties . TotalByteCount . Type , at position: Int ) {
576
554
let parents = state. withLock { state in
577
- state. children [ position] . totalByteCount. isDirty = true
578
- return state. parents
555
+ state. markChildDirty ( property: property, at: position)
579
556
}
580
557
markSelfDirty ( property: property, parents: parents)
581
558
}
582
559
583
560
internal func markChildDirty( property: ProgressManager . Properties . CompletedByteCount . Type , at position: Int ) {
584
561
let parents = state. withLock { state in
585
- state. children [ position] . completedByteCount. isDirty = true
586
- return state. parents
562
+ state. markChildDirty ( property: property, at: position)
587
563
}
588
564
markSelfDirty ( property: property, parents: parents)
589
565
}
590
566
591
567
internal func markChildDirty( property: ProgressManager . Properties . Throughput . Type , at position: Int ) {
592
568
let parents = state. withLock { state in
593
- state. children [ position] . throughput. isDirty = true
594
- return state. parents
569
+ state. markChildDirty ( property: property, at: position)
595
570
}
596
571
markSelfDirty ( property: property, parents: parents)
597
572
}
598
573
599
574
internal func markChildDirty( property: ProgressManager . Properties . EstimatedTimeRemaining . Type , at position: Int ) {
600
575
let parents = state. withLock { state in
601
- state. children [ position] . estimatedTimeRemaining. isDirty = true
602
- return state. parents
576
+ state. markChildDirty ( property: property, at: position)
603
577
}
604
578
markSelfDirty ( property: property, parents: parents)
605
579
}
0 commit comments