Skip to content

Commit 9e5b336

Browse files
committed
apply naming changes
1 parent e2c875b commit 9e5b336

File tree

4 files changed

+81
-84
lines changed

4 files changed

+81
-84
lines changed

Sources/FoundationEssentials/ProgressReporter/ProgressReporter+Interop.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ internal import _ForSwiftFoundation
2121
// Actual ProgressReporter Child
2222
extension Progress {
2323

24-
/// Returns a ProgressReporter.Progress which can be passed to any method that reports progress
24+
/// Returns a Subprogress which can be passed to any method that reports progress
2525
/// and can be initialized into a child `ProgressReporter` to the `self`.
2626
///
2727
/// Delegates a portion of totalUnitCount to a future child `ProgressReporter` instance.
2828
///
2929
/// - Parameter count: Number of units delegated to a child instance of `ProgressReporter`
30-
/// which may be instantiated by `ProgressReporter.Progress` later when `reporter(totalCount:)` is called.
31-
/// - Returns: A `ProgressReporter.Progress` instance.
32-
public func makeChild(withPendingUnitCount count: Int) -> ProgressReporter.Progress {
30+
/// which may be instantiated by `Subprogress` later when `reporter(totalCount:)` is called.
31+
/// - Returns: A `Subprogress` instance.
32+
public func makeChild(withPendingUnitCount count: Int) -> Subprogress {
3333

3434
// Make ghost parent & add it to actual parent's children list
3535
let ghostProgressParent = Progress(totalUnitCount: Int64(count))
@@ -42,7 +42,7 @@ extension Progress {
4242
let observation = _ProgressParentProgressReporterChild(ghostParent: ghostProgressParent, ghostChild: ghostReporterChild)
4343

4444
// Make actual child with ghost child being parent
45-
var actualProgress = ghostReporterChild.assign(count: count)
45+
var actualProgress = ghostReporterChild.subprogress(assigningCount: count)
4646
actualProgress.observation = observation
4747
actualProgress.ghostReporter = ghostReporterChild
4848
actualProgress.interopWithProgressParent = true
@@ -88,7 +88,7 @@ extension ProgressReporter {
8888
/// - Parameters:
8989
/// - count: Number of units delegated from `self`'s `totalCount`.
9090
/// - progress: `Progress` which receives the delegated `count`.
91-
public func assign(count: Int, to progress: Foundation.Progress) {
91+
public func subprogress(assigningCount count: Int, to progress: Foundation.Progress) {
9292
let parentBridge = _NSProgressParentBridge(reporterParent: self)
9393
progress._setParent(parentBridge, portion: Int64(count))
9494

Sources/FoundationEssentials/ProgressReporter/ProgressReporter+Progress.swift

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,44 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
@available(FoundationPreview 6.2, *)
14-
// ProgressReporter.Progress
15-
extension ProgressReporter {
16-
/// ProgressReporter.Progress is a nested ~Copyable struct used to establish parent-child relationship between two instances of ProgressReporter.
17-
///
18-
/// ProgressReporter.Progress is returned from a call to `assign(count:)` by a parent ProgressReporter.
19-
/// A child ProgressReporter is then returned by calling`reporter(totalCount:)` on a ProgressReporter.Progress.
20-
public struct Progress: ~Copyable, Sendable {
21-
internal var parent: ProgressReporter
22-
internal var portionOfParent: Int
23-
internal var isInitializedToProgressReporter: Bool
14+
/// Subprogress is a nested ~Copyable struct used to establish parent-child relationship between two instances of ProgressReporter.
15+
///
16+
/// Subprogress is returned from a call to `subprogress(assigningCount:)` by a parent ProgressReporter.
17+
/// A child ProgressReporter is then returned by calling`reporter(totalCount:)` on a Subprogress.
18+
public struct Subprogress: ~Copyable, Sendable {
19+
internal var parent: ProgressReporter
20+
internal var portionOfParent: Int
21+
internal var isInitializedToProgressReporter: Bool
22+
23+
// Interop variables for Progress - ProgressReporter Interop
24+
internal var interopWithProgressParent: Bool = false
25+
// To be kept alive in ProgressReporter
26+
internal var observation: (any Sendable)?
27+
internal var ghostReporter: ProgressReporter?
28+
29+
internal init(parent: ProgressReporter, portionOfParent: Int) {
30+
self.parent = parent
31+
self.portionOfParent = portionOfParent
32+
self.isInitializedToProgressReporter = false
33+
}
34+
35+
/// Instantiates a ProgressReporter which is a child to the parent from which `self` is returned.
36+
/// - Parameter totalCount: Total count of returned child `ProgressReporter` instance.
37+
/// - Returns: A `ProgressReporter` instance.
38+
public consuming func reporter(totalCount: Int?) -> ProgressReporter {
39+
isInitializedToProgressReporter = true
2440

25-
// Interop variables for Progress - ProgressReporter Interop
26-
internal var interopWithProgressParent: Bool = false
27-
// To be kept alive in ProgressReporter
28-
internal var observation: (any Sendable)?
29-
internal var ghostReporter: ProgressReporter?
30-
31-
internal init(parent: ProgressReporter, portionOfParent: Int) {
32-
self.parent = parent
33-
self.portionOfParent = portionOfParent
34-
self.isInitializedToProgressReporter = false
35-
}
41+
let childReporter = ProgressReporter(total: totalCount, parent: parent, portionOfParent: portionOfParent, ghostReporter: ghostReporter, interopObservation: observation)
3642

37-
/// Instantiates a ProgressReporter which is a child to the parent from which `self` is returned.
38-
/// - Parameter totalCount: Total count of returned child `ProgressReporter` instance.
39-
/// - Returns: A `ProgressReporter` instance.
40-
public consuming func reporter(totalCount: Int?) -> ProgressReporter {
41-
isInitializedToProgressReporter = true
42-
43-
let childReporter = ProgressReporter(total: totalCount, parent: parent, portionOfParent: portionOfParent, ghostReporter: ghostReporter, interopObservation: observation)
44-
45-
if interopWithProgressParent {
46-
// Set interop child of ghost reporter so ghost reporter reads from here
47-
ghostReporter?.setInteropChild(interopChild: childReporter)
48-
} else {
49-
// Add child to parent's _children list
50-
parent.addToChildren(childReporter: childReporter)
51-
}
52-
53-
return childReporter
43+
if interopWithProgressParent {
44+
// Set interop child of ghost reporter so ghost reporter reads from here
45+
ghostReporter?.setInteropChild(interopChild: childReporter)
46+
} else {
47+
// Add child to parent's _children list
48+
parent.addToChildren(childReporter: childReporter)
5449
}
50+
51+
return childReporter
5552
}
5653
}
54+

Sources/FoundationEssentials/ProgressReporter/ProgressReporter.swift

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -269,17 +269,16 @@ internal struct AnyMetatypeWrapper: Hashable, Equatable, Sendable {
269269
}
270270

271271

272-
/// Returns a `ProgressReporter.Progress` representing a portion of `self`which can be passed to any method that reports progress.
272+
/// Returns a `Subprogress` representing a portion of `self`which can be passed to any method that reports progress.
273273
///
274-
/// - Parameter count: Units, which is a portion of `totalCount`delegated to an instance of `ProgressReporter.Progress`.
275-
/// - Returns: A `ProgressReporter.Progress` instance.
276-
public func assign(count portionOfParent: Int) -> Progress {
274+
/// - Parameter count: Units, which is a portion of `totalCount`delegated to an instance of `Subprogress`.
275+
/// - Returns: A `Subprogress` instance.
276+
public func subprogress(assigningCount portionOfParent: Int) -> Subprogress {
277277
precondition(portionOfParent > 0, "Giving out zero units is not a valid operation.")
278-
let childProgress = Progress(parent: self, portionOfParent: portionOfParent)
279-
return childProgress
278+
let subprogress = Subprogress(parent: self, portionOfParent: portionOfParent)
279+
return subprogress
280280
}
281281

282-
283282
/// Increases `completedCount` by `count`.
284283
/// - Parameter count: Units of work.
285284
public func complete(count: Int) {

0 commit comments

Comments
 (0)