@@ -66,9 +66,9 @@ internal struct AnyMetatypeWrapper: Hashable, Equatable, Sendable {
66
66
internal let interopObservationForMonitor : LockedState < ( any Sendable ) ? > = LockedState ( initialState: nil )
67
67
internal let monitorInterop : LockedState < Bool > = LockedState ( initialState: false )
68
68
69
- #if FOUNDATION_FRAMEWORK
69
+ #if FOUNDATION_FRAMEWORK
70
70
internal let parentBridge : LockedState < Foundation . Progress ? > = LockedState ( initialState: nil ) // dummy, set upon calling setParentBridge
71
- #endif
71
+ #endif
72
72
// Interop properties - Actually set and called
73
73
internal let ghostReporter : ProgressManager ? // set at init, used to call notify observers
74
74
internal let observers : LockedState < [ @Sendable ( ObserverState ) -> Void ] > = LockedState ( initialState: [ ] ) // storage for all observers, set upon calling addObservers
@@ -340,8 +340,10 @@ internal struct AnyMetatypeWrapper: Hashable, Equatable, Sendable {
340
340
}
341
341
342
342
/// Mutates any settable properties that convey information about progress.
343
- public func withProperties< T> ( _ closure: @Sendable ( inout Values ) throws -> T ) rethrows -> T {
344
- return try state. withLock { state in
343
+ public func withProperties< T, E: Error > (
344
+ _ closure: ( inout sending Values) throws ( E ) -> sending T
345
+ ) throws ( E) -> sending T {
346
+ return try state. withLock { ( state) throws ( E) -> T in
345
347
var values = Values ( manager: self , state: state)
346
348
// This is done to avoid copy on write later
347
349
state = State ( fractionState: FractionState ( indeterminate: true , selfFraction: _ProgressFraction ( ) , childFraction: _ProgressFraction ( ) ) , otherProperties: [ : ] , childrenOtherProperties: [ : ] )
@@ -351,24 +353,6 @@ internal struct AnyMetatypeWrapper: Hashable, Equatable, Sendable {
351
353
}
352
354
}
353
355
354
- // public func withProperties<T, E: Error>(
355
- // _ closure: (inout sending Values) throws(E) -> sending T
356
- // ) throws(E) -> sending T {
357
- // return try state.withLock { state in
358
- // var values = Values(manager: self, state: state)
359
- // // This is done to avoid copy on write later
360
- // state = State(fractionState: FractionState(indeterminate: true, selfFraction: _ProgressFraction(), childFraction: _ProgressFraction()), otherProperties: [:], childrenOtherProperties: [:])
361
- //
362
- // do {
363
- // let result = try closure(&values)
364
- // state = values.state
365
- // return result
366
- // } catch let localError {
367
- // throw localError as! E
368
- // }
369
- // }
370
- // }
371
-
372
356
//MARK: ProgressManager Properties getters
373
357
/// Returns nil if `self` was instantiated without total units;
374
358
/// returns a `Int` value otherwise.
@@ -468,7 +452,7 @@ internal struct AnyMetatypeWrapper: Hashable, Equatable, Sendable {
468
452
469
453
if next. isFinished {
470
454
// Remove from children list
471
- // _ = children.withLock { $0.remove(self) }
455
+ // _ = children.withLock { $0.remove(self) }
472
456
473
457
if portion != 0 {
474
458
// Update our self completed units
@@ -506,7 +490,7 @@ internal struct AnyMetatypeWrapper: Hashable, Equatable, Sendable {
506
490
observation = monitorObservation
507
491
}
508
492
}
509
-
493
+
510
494
internal func setMonitorInterop( to value: Bool ) {
511
495
monitorInterop. withLock { monitorInterop in
512
496
monitorInterop = value
@@ -556,8 +540,10 @@ internal struct AnyMetatypeWrapper: Hashable, Equatable, Sendable {
556
540
parentReporter. updateChildFraction ( from: updates. 0 , to: updates. 1 , portion: portionOfParent)
557
541
}
558
542
559
- internal func getAdditionalProperties< T> ( _ closure: @Sendable ( Values) throws -> T ) rethrows -> T {
560
- try state. withLock { state in
543
+ internal func getAdditionalProperties< T, E: Error > (
544
+ _ closure: ( sending Values) throws ( E ) -> sending T
545
+ ) throws ( E) -> sending T {
546
+ try state. withLock { state throws ( E) -> T in
561
547
let values = Values ( manager: self , state: state)
562
548
// No need to modify state since this is read-only
563
549
let result = try closure ( values)
0 commit comments