Skip to content

Commit 62968b6

Browse files
committed
Revise editorial changes.
1 parent 6a79590 commit 62968b6

File tree

4 files changed

+121
-111
lines changed

4 files changed

+121
-111
lines changed

stdlib/public/Concurrency/Task.swift

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,29 @@ import Swift
2222
/// Tasks can start running immediately after creation;
2323
/// you don't explicitly start or schedule them.
2424
/// After creating a task, you use the instance to interact with it ---
25-
/// for example, to wait for it to complete or to cancel.
25+
/// for example, to wait for it to complete or to cancel it.
2626
/// It's not a programming error to discard a reference to a task
2727
/// without waiting for that task to finish or canceling it.
28-
/// A task runs regardless of whether<!-- EDIT: Don't use "whether or not". --> you keep a reference to it.
28+
/// A task runs regardless of whether you keep a reference to it.
2929
/// However, if you discard the reference to a task,
3030
/// you give up the ability
31-
/// to wait for that task's result or if it's canceled.
31+
/// to wait for that task's result or cancel the task.
3232
///
3333
/// To support operations on the current task,
3434
/// which can be either a detached task or child task,
3535
/// `Task` also exposes class methods like `yield()`.
3636
/// Because these methods are asynchronous,
3737
/// they're always invoked as part of an existing task.
3838
///
39-
/// Only code that's running as part of the task can interact with that task
40-
/// by invoking the appropriate context-sensitive static functions which operate
41-
/// on the current task.<!-- FIXME: Long sentence that could probably be split in two. -->
39+
/// Only code that's running as part of the task can interact with that task.
40+
/// To interact with the current task,
41+
/// you call one of the static methods on `Task`.
4242
///
4343
/// A task's execution can be seen as a series of periods where the task ran.
4444
/// Each such period ends at a suspension point or the
4545
/// completion of the task.
46-
///
47-
/// These partial periods towards<!-- FIXME: The preceding wording is a little awkward; please rewrite. --> the task's completion are `PartialAsyncTask`.
48-
/// Unless you're implementing a scheduler,
46+
/// These periods of execution are represented by instances of `PartialAsyncTask`.
47+
/// Unless you're implementing a custom executor,
4948
/// you don't directly interact with partial tasks.
5049
///
5150
/// For information about the language-level concurrency model that `Task` is part of,
@@ -91,10 +90,11 @@ public struct Task<Success, Failure: Error>: Sendable {
9190

9291
@available(SwiftStdlib 5.5, *)
9392
extension Task {
94-
/// Wait for the task to complete, then return its result or throw an error.
93+
/// The result from a throwing task, after it completes.
9594
///
9695
/// If the task hasn't completed,
97-
/// its priority increases to that of the current task.
96+
/// accessing this property waits for it to complete
97+
/// and its priority increases to that of the current task.
9898
/// Note that this might not be as effective as
9999
/// creating the task with the correct priority,
100100
/// depending on the executor's scheduling details.
@@ -110,11 +110,14 @@ extension Task {
110110
}
111111
}
112112

113-
/// Wait for the task to complete, then return its result or error.
113+
/// The result or error from a throwing task, after it completes.
114114
///
115-
/// If the task hasn't completed, its priority increases to the
116-
/// priority of the current task. Note that this isn't as effective as
117-
/// creating the task with the correct priority.
115+
/// If the task hasn't completed,
116+
/// accessing this property waits for it to complete
117+
/// and its priority increases to that of the current task.
118+
/// Note that this might not be as effective as
119+
/// creating the task with the correct priority,
120+
/// depending on the executor's scheduling details.
118121
///
119122
/// - Returns: If the task succeeded,
120123
/// `.success` with the task's result as the associated value;
@@ -129,7 +132,7 @@ extension Task {
129132
}
130133
}
131134

132-
/// Indicate for the task to stop.
135+
/// Indicates that the task should stop running.
133136
///
134137
/// Task cancellation is cooperative:
135138
/// a task that supports cancellation
@@ -149,10 +152,11 @@ extension Task {
149152

150153
@available(SwiftStdlib 5.5, *)
151154
extension Task where Failure == Never {
152-
/// Wait for the task to complete and return its result.
155+
/// The result from a nonthrowing task, after it completes.
153156
///
154157
/// If the task hasn't completed yet,
155-
/// its priority increases to that of the current task.
158+
/// accessing this property waits for it to complete
159+
/// and its priority increases to that of the current task.
156160
/// Note that this might not be as effective as
157161
/// creating the task with the correct priority,
158162
/// depending on the executor's scheduling details.
@@ -191,7 +195,7 @@ extension Task: Equatable {
191195
/// Typically, executors attempt to run tasks with a higher priority
192196
/// before tasks with a lower priority.
193197
/// However, the semantics of how priority is treated are left up to each
194-
/// platform and `Executor` implementation.<!-- QUERY: Should there be an article before Executor? -->
198+
/// platform and `Executor` implementation.
195199
///
196200
/// Child tasks automatically inherit their parent task's priority.
197201
/// Detached tasks created by `detach(priority:operation:)` don't inherit task priority
@@ -211,7 +215,7 @@ extension Task: Equatable {
211215
/// then the priority of this task increases until the task completes.
212216
///
213217
/// In both cases, priority elevation helps you prevent a low-priority task
214-
/// that blocks the execution of a high priority task,
218+
/// from blocking the execution of a high priority task,
215219
/// which is also known as *priority inversion*.
216220
@available(SwiftStdlib 5.5, *)
217221
public struct TaskPriority: RawRepresentable, Sendable {
@@ -546,7 +550,7 @@ extension Task where Failure == Never {
546550
/// Runs the given nonthrowing operation asynchronously
547551
/// as part of a new top-level task.
548552
///
549-
/// Don't use a detached task unless it isn't possible
553+
/// Don't use a detached task if it's possible
550554
/// to model the operation using structured concurrency features like child tasks.
551555
/// Child tasks inherit the parent task's priority and task-local storage,
552556
/// and canceling a parent task automatically cancels all of its child tasks.
@@ -593,7 +597,7 @@ extension Task where Failure == Error {
593597
///
594598
/// If the operation throws an error, this method propogates that error.
595599
///
596-
/// Don't use a detached task unless it isn't possible
600+
/// Don't use a detached task if it's possible
597601
/// to model the operation using structured concurrency features like child tasks.
598602
/// Child tasks inherit the parent task's priority and task-local storage,
599603
/// and canceling a parent task automatically cancels all of its child tasks.
@@ -746,7 +750,7 @@ public struct UnsafeCurrentTask {
746750

747751
/// A Boolean value that indicates whether the current task was canceled.
748752
///
749-
/// After the value of this property is `true`, it remains `true` indefinitely.
753+
/// After the value of this property becomes `true`, it remains `true` indefinitely.
750754
/// There is no way to uncancel a task.
751755
///
752756
/// - SeeAlso: `checkCancellation()`

stdlib/public/Concurrency/TaskCancellation.swift

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ import Swift
1616
// ==== Task Cancellation ------------------------------------------------------
1717

1818
/// Execute an operation with a cancellation handler that's immediately
19-
/// invoked if the current task is canceled<!-- FIXME: Passive; rewrite. -->.
19+
/// invoked if the current task is canceled.
2020
///
2121
/// This differs from the operation cooperatively checking for cancellation
2222
/// and reacting to it in that the cancellation handler is _always_ and
23-
/// _immediately_ invoked when the task is canceled<!-- FIXME: Passive; rewrite. -->. For example, even if the
23+
/// _immediately_ invoked when the task is canceled. For example, even if the
2424
/// operation is running code that never checks for cancellation, a cancellation
2525
/// handler still runs and provides a chance to run some cleanup code.
2626
///
@@ -44,7 +44,10 @@ public func withTaskCancellationHandler<T>(
4444

4545
@available(SwiftStdlib 5.5, *)
4646
extension Task {
47-
/// Returns `true`<!-- FIXME: If this is an abstract, don't include code font or links. --> if the task is canceled<!-- FIXME: Passive; rewrite. -->, and should stop executing.
47+
/// A Boolean value that indicates whether the task should stop executing.
48+
///
49+
/// After the value of this property becomes `true`, it remains `true` indefinitely.
50+
/// There is no way to uncancel a task.
4851
///
4952
/// - SeeAlso: `checkCancellation()`
5053
public var isCancelled: Bool {
@@ -60,10 +63,10 @@ extension Task {
6063

6164
@available(SwiftStdlib 5.5, *)
6265
extension Task where Success == Never, Failure == Never {
63-
/// Returns `true` if the task is canceled, and should stop executing.<!-- FIXME: Abstracts need to be unique; this is copy/pasted from what's on line 47, which means it carries the same problems. Rewrite the abstract so that this is different from the one on line 47. What sets it apart? Why would someone use this over the previous? -->
66+
/// A Boolean value that indicates whether the task should stop executing.
6467
///
65-
/// If no current `Task` is available, returns `false`, as outside of a task
66-
/// context no task cancellation may be observed<!-- FIXME: Passive; rewrite. -->.
68+
/// After the value of this property becomes `true`, it remains `true` indefinitely.
69+
/// There is no way to uncancel a task.
6770
///
6871
/// - SeeAlso: `checkCancellation()`
6972
public static var isCancelled: Bool {
@@ -75,7 +78,7 @@ extension Task where Success == Never, Failure == Never {
7578

7679
@available(SwiftStdlib 5.5, *)
7780
extension Task where Success == Never, Failure == Never {
78-
/// Check if the task is canceled<!-- FIXME: Passive; rewrite. --> and throw an `CancellationError`<!-- FIXME: Don't include symbols in abstracts. --> if it was.
81+
/// Throws an error if the task was canceled.
7982
///
8083
/// The error is always an instance of `Task.CancellationError`.
8184
///
@@ -87,10 +90,10 @@ extension Task where Success == Never, Failure == Never {
8790
}
8891
}
8992

90-
/// The default cancellation thrown when a task is canceled<!-- FIXME: Passive; rewrite. -->.
93+
/// An error that indicates a task was canceled.
9194
///
9295
/// This error is also thrown automatically by `Task.checkCancellation()`,
93-
/// if the current task has been canceled<!-- FIXME: Passive; rewrite. -->.
96+
/// if the current task has been canceled.
9497
@available(SwiftStdlib 5.5, *)
9598
public struct CancellationError: Error {
9699
// no extra information, cancellation is intended to be light-weight

0 commit comments

Comments
 (0)