@@ -21,8 +21,8 @@ internal import OrderedCollections
21
21
internal import _FoundationCollections
22
22
#endif
23
23
24
- @available ( FoundationPreview 6 . 3 , * )
25
24
/// An object that conveys ongoing progress to the user for a specified task.
25
+ @available ( FoundationPreview 6 . 3 , * )
26
26
@Observable public final class ProgressManager : Sendable {
27
27
28
28
internal let state : Mutex < State >
@@ -38,7 +38,6 @@ internal import _FoundationCollections
38
38
}
39
39
40
40
/// The completed units of work.
41
- /// If `self` is indeterminate, the value will be 0.
42
41
public var completedCount : Int {
43
42
_ $observationRegistrar. access ( self , keyPath: \. completedCount)
44
43
return state. withLock { state in
@@ -48,7 +47,7 @@ internal import _FoundationCollections
48
47
49
48
/// The proportion of work completed.
50
49
/// This takes into account the fraction completed in its children instances if children are present.
51
- /// If `self` is indeterminate, the value will be 0.
50
+ /// If `self` is indeterminate, the value will be 0.0.
52
51
public var fractionCompleted : Double {
53
52
_ $observationRegistrar. access ( self , keyPath: \. fractionCompleted)
54
53
return state. withLock { state in
@@ -151,7 +150,7 @@ internal import _FoundationCollections
151
150
/// If the `Subprogress` is not converted into a `ProgressManager` (for example, due to an error or early return),
152
151
/// then the assigned count is marked as completed in the parent `ProgressManager`.
153
152
///
154
- /// - Parameter count: Units, which is a portion of `totalCount`delegated to an instance of `Subprogress`.
153
+ /// - Parameter count: The portion of `totalCount` to be delegated to the `Subprogress`.
155
154
/// - Returns: A `Subprogress` instance.
156
155
public func subprogress( assigningCount portionOfParent: Int ) -> Subprogress {
157
156
precondition ( portionOfParent > 0 , " Giving out zero units is not a valid operation. " )
@@ -160,9 +159,12 @@ internal import _FoundationCollections
160
159
}
161
160
162
161
/// Adds a `ProgressReporter` as a child, with its progress representing a portion of `self`'s progress.
162
+ ///
163
+ /// If a cycle is detected, this will cause a crash at runtime.
164
+ ///
163
165
/// - Parameters:
164
- /// - reporter: A `ProgressReporter` instance.
165
166
/// - count: Units, which is a portion of `totalCount`delegated to an instance of `Subprogress`.
167
+ /// - reporter: A `ProgressReporter` instance.
166
168
public func assign( count: Int , to reporter: ProgressReporter ) {
167
169
precondition ( isCycle ( reporter: reporter) == false , " Creating a cycle is not allowed. " )
168
170
@@ -407,6 +409,7 @@ extension ProgressManager: Hashable, Equatable {
407
409
408
410
@available ( FoundationPreview 6 . 3 , * )
409
411
extension ProgressManager : CustomStringConvertible , CustomDebugStringConvertible {
412
+ /// A description.
410
413
public var description : String {
411
414
return """
412
415
Class Name: ProgressManager
@@ -425,6 +428,7 @@ extension ProgressManager: CustomStringConvertible, CustomDebugStringConvertible
425
428
"""
426
429
}
427
430
431
+ /// A debug description.
428
432
public var debugDescription : String {
429
433
return self . description
430
434
}
0 commit comments