@@ -66,9 +66,9 @@ internal struct AnyMetatypeWrapper: Hashable, Equatable, Sendable {
6666 internal let interopObservationForMonitor : LockedState < ( any Sendable ) ? > = LockedState ( initialState: nil )
6767 internal let monitorInterop : LockedState < Bool > = LockedState ( initialState: false )
6868
69- #if FOUNDATION_FRAMEWORK
69+ #if FOUNDATION_FRAMEWORK
7070 internal let parentBridge : LockedState < Foundation . Progress ? > = LockedState ( initialState: nil ) // dummy, set upon calling setParentBridge
71- #endif
71+ #endif
7272 // Interop properties - Actually set and called
7373 internal let ghostReporter : ProgressManager ? // set at init, used to call notify observers
7474 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 {
340340 }
341341
342342 /// 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
345347 var values = Values ( manager: self , state: state)
346348 // This is done to avoid copy on write later
347349 state = State ( fractionState: FractionState ( indeterminate: true , selfFraction: _ProgressFraction ( ) , childFraction: _ProgressFraction ( ) ) , otherProperties: [ : ] , childrenOtherProperties: [ : ] )
@@ -351,24 +353,6 @@ internal struct AnyMetatypeWrapper: Hashable, Equatable, Sendable {
351353 }
352354 }
353355
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-
372356 //MARK: ProgressManager Properties getters
373357 /// Returns nil if `self` was instantiated without total units;
374358 /// returns a `Int` value otherwise.
@@ -468,7 +452,7 @@ internal struct AnyMetatypeWrapper: Hashable, Equatable, Sendable {
468452
469453 if next. isFinished {
470454 // Remove from children list
471- // _ = children.withLock { $0.remove(self) }
455+ // _ = children.withLock { $0.remove(self) }
472456
473457 if portion != 0 {
474458 // Update our self completed units
@@ -506,7 +490,7 @@ internal struct AnyMetatypeWrapper: Hashable, Equatable, Sendable {
506490 observation = monitorObservation
507491 }
508492 }
509-
493+
510494 internal func setMonitorInterop( to value: Bool ) {
511495 monitorInterop. withLock { monitorInterop in
512496 monitorInterop = value
@@ -556,8 +540,10 @@ internal struct AnyMetatypeWrapper: Hashable, Equatable, Sendable {
556540 parentReporter. updateChildFraction ( from: updates. 0 , to: updates. 1 , portion: portionOfParent)
557541 }
558542
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
561547 let values = Values ( manager: self , state: state)
562548 // No need to modify state since this is read-only
563549 let result = try closure ( values)
0 commit comments