Skip to content

Commit 1036417

Browse files
committed
Apply changes from editorial.
Changes from <rdar://81715064>
1 parent 6492386 commit 1036417

File tree

4 files changed

+152
-152
lines changed

4 files changed

+152
-152
lines changed

stdlib/public/Concurrency/Task.swift

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,34 @@ 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 in.
25+
/// for example, to wait for it to complete or to cancel.
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 whether or not you keep a reference to it.
28+
/// A task runs regardless of whether<!-- EDIT: Don't use "whether or not". --> 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 cancel the task.
31+
/// to wait for that task's result or if it's canceled.
3232
///
3333
/// To support operations on the current task,
34-
/// which can be either a detached task or a child task,
34+
/// 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,
39+
/// Only code that's running as part of the task can interact with that task
4040
/// by invoking the appropriate context-sensitive static functions which operate
41-
/// on the current task.
41+
/// on the current task.<!-- FIXME: Long sentence that could probably be split in two. -->
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.
4646
///
47-
/// These partial periods towards the task's completion are `PartialAsyncTask`.
47+
/// These partial periods towards<!-- FIXME: The preceding wording is a little awkward; please rewrite. --> the task's completion are `PartialAsyncTask`.
4848
/// Unless you're implementing a scheduler,
49-
/// you don't generally interact with partial tasks directly.
49+
/// you don't directly interact with partial tasks.
5050
///
5151
/// For information about the language-level concurrency model that `Task` is part of,
52-
/// see [Concurrency][concurrency] in *[The Swift Programming Language][tspl]*.
52+
/// see [Concurrency][concurrency] in [The Swift Programming Language][tspl].
5353
///
5454
/// [concurrency]: https://docs.swift.org/swift-book/LanguageGuide/Concurrency.html
5555
/// [tspl]: https://docs.swift.org/swift-book/
@@ -91,9 +91,9 @@ public struct Task<Success, Failure: Error>: Sendable {
9191

9292
@available(SwiftStdlib 5.5, *)
9393
extension Task {
94-
/// Wait for the task to complete, returning its result or throwing an error.
94+
/// Wait for the task to complete, then return its result or throw an error.
9595
///
96-
/// If the task hasn't completed yet,
96+
/// If the task hasn't completed,
9797
/// 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,
@@ -110,9 +110,9 @@ extension Task {
110110
}
111111
}
112112

113-
/// Wait for the task to complete, returning its result or its error.
113+
/// Wait for the task to complete, then return its result or error.
114114
///
115-
/// If the task hasn't completed yet, its priority increases to the
115+
/// If the task hasn't completed, its priority increases to the
116116
/// priority of the current task. Note that this isn't as effective as
117117
/// creating the task with the correct priority.
118118
///
@@ -129,7 +129,7 @@ extension Task {
129129
}
130130
}
131131

132-
/// Indicate that the task should stop.
132+
/// Indicate for the task to stop.
133133
///
134134
/// Task cancellation is cooperative:
135135
/// a task that supports cancellation
@@ -149,7 +149,7 @@ extension Task {
149149

150150
@available(SwiftStdlib 5.5, *)
151151
extension Task where Failure == Never {
152-
/// Wait for the task to complete, returning its result.
152+
/// Wait for the task to complete and return its result.
153153
///
154154
/// If the task hasn't completed yet,
155155
/// its priority increases to that of the current task.
@@ -191,7 +191,7 @@ extension Task: Equatable {
191191
/// Typically, executors attempt to run tasks with a higher priority
192192
/// before tasks with a lower priority.
193193
/// However, the semantics of how priority is treated are left up to each
194-
/// platform and `Executor` implementation.
194+
/// platform and `Executor` implementation.<!-- QUERY: Should there be an article before Executor? -->
195195
///
196196
/// Child tasks automatically inherit their parent task's priority.
197197
/// Detached tasks created by `detach(priority:operation:)` don't inherit task priority
@@ -206,12 +206,12 @@ extension Task: Equatable {
206206
/// then the actor's current task is temporarily elevated
207207
/// to the priority of the enqueued task.
208208
/// This priority elevation allows the new task
209-
/// to be processed at (effectively) the priority it was enqueued with.
209+
/// to be processed at the priority it was enqueued with.
210210
/// - If a a higher-priority task calls the `get()` method,
211211
/// then the priority of this task increases until the task completes.
212212
///
213213
/// In both cases, priority elevation helps you prevent a low-priority task
214-
/// blocking the execution of a high priority task,
214+
/// that blocks the execution of a high priority task,
215215
/// which is also known as *priority inversion*.
216216
@available(SwiftStdlib 5.5, *)
217217
public struct TaskPriority: RawRepresentable, Sendable {
@@ -284,7 +284,7 @@ extension Task where Success == Never, Failure == Never {
284284
/// this property's value is `Priority.default`.
285285
public static var currentPriority: TaskPriority {
286286
withUnsafeCurrentTask { task in
287-
// If we are running on behalf of a task, use that task's priority.
287+
// If running on behalf of a task, use that task's priority.
288288
if let task = task {
289289
return task.priority
290290
}
@@ -307,7 +307,7 @@ extension TaskPriority {
307307

308308
/// Flags for schedulable jobs.
309309
///
310-
/// This is a port of the C++ FlagSet.
310+
/// This is a port of the C++ FlagSet<!-- FIXME: Rewrite so you're not using FlagSet in the abstract. -->.
311311
@available(SwiftStdlib 5.5, *)
312312
struct JobFlags {
313313
/// Kinds of schedulable jobs.
@@ -329,7 +329,7 @@ struct JobFlags {
329329
}
330330
}
331331

332-
/// Whether this is an asynchronous task.
332+
/// Whether this is an asynchronous task.<!-- FIXME: All of these "Whether" statements need to be rewritten to be clearer. What does "Whether" tie into? That part of these one-line descriptions doesn't work. Fix here and throughout the remainder of these for this section. Also, should the lines terminate with a colon instead of a period? -->
333333
var isAsyncTask: Bool { kind == .task }
334334

335335
/// The priority given to the job.
@@ -414,7 +414,7 @@ struct JobFlags {
414414

415415
// ==== Task Creation Flags --------------------------------------------------
416416

417-
/// Form task creation flags for use with the createAsyncTask builtins.
417+
/// Form task creation flags for use with the `createAsyncTask`<!-- FIXME: If this is an abstract, you'll need to rewrite so you're not including createAsyncTask here. --> built-ins<!-- FIXME: Hyphenate. -->.
418418
@available(SwiftStdlib 5.5, *)
419419
@_alwaysEmitIntoClient
420420
func taskCreateFlags(
@@ -546,7 +546,7 @@ extension Task where Failure == Never {
546546
/// Runs the given nonthrowing operation asynchronously
547547
/// as part of a new top-level task.
548548
///
549-
/// Avoid using a detached task unless it isn't possible
549+
/// Don't use a detached task unless it isn't possible
550550
/// to model the operation using structured concurrency features like child tasks.
551551
/// Child tasks inherit the parent task's priority and task-local storage,
552552
/// and canceling a parent task automatically cancels all of its child tasks.
@@ -593,7 +593,7 @@ extension Task where Failure == Error {
593593
///
594594
/// If the operation throws an error, this method propogates that error.
595595
///
596-
/// Avoid using a detached task unless it isn't possible
596+
/// Don't use a detached task unless it isn't possible
597597
/// to model the operation using structured concurrency features like child tasks.
598598
/// Child tasks inherit the parent task's priority and task-local storage,
599599
/// and canceling a parent task automatically cancels all of its child tasks.
@@ -656,7 +656,7 @@ extension Task where Success == Never, Failure == Never {
656656
/// in the middle of a long-running operation
657657
/// that doesn't contain any suspension points,
658658
/// to let other tasks run for a while
659-
/// before execution returns back to this task.
659+
/// before execution returns to this task.
660660
///
661661
/// If this task is the highest-priority task in the system,
662662
/// the executor immediately resumes execution of the same task.
@@ -677,15 +677,15 @@ extension Task where Success == Never, Failure == Never {
677677
/// Calls a closure with an unsafe reference to the current task.
678678
///
679679
/// If you call this function from the body of an asynchronous function,
680-
/// the unsafe task handle passed to the closure is always non-nil
680+
/// the unsafe task handle passed to the closure is always non-`nil`
681681
/// because an asynchronous function always runs in the context of a task.
682-
/// However if you call this function from the body of a synchronous function,
682+
/// However, if you call this function from the body of a synchronous function,
683683
/// and that function isn't executing in the context of any task,
684684
/// the unsafe task handle is `nil`.
685685
///
686686
/// Don't store an unsafe task reference
687687
/// for use outside this method's closure.
688-
/// Storing an unsafe reference doesn't impact the task's actual life cycle,
688+
/// Storing an unsafe reference doesn't affect the task's actual life cycle,
689689
/// and the behavior of accessing an unsafe task reference
690690
/// outside of the `withUnsafeCurrentTask(body:)` method's closure isn't defined.
691691
/// Instead, use the `task` property of `UnsafeCurrentTask`
@@ -719,7 +719,7 @@ public func withUnsafeCurrentTask<T>(body: (UnsafeCurrentTask?) throws -> T) ret
719719
/// call the `withUnsafeCurrentTask(body:)` method.
720720
/// Don't store an unsafe task reference
721721
/// for use outside that method's closure.
722-
/// Storing an unsafe reference doesn't impact the task's actual life cycle,
722+
/// Storing an unsafe reference doesn't affect the task's actual life cycle,
723723
/// and the behavior of accessing an unsafe task reference
724724
/// outside of the `withUnsafeCurrentTask(body:)` method's closure isn't defined.
725725
///
@@ -731,7 +731,7 @@ public func withUnsafeCurrentTask<T>(body: (UnsafeCurrentTask?) throws -> T) ret
731731
/// and may lead to crashes or data loss.
732732
///
733733
/// For information about the language-level concurrency model that `UnsafeCurrentTask` is part of,
734-
/// see [Concurrency][concurrency] in *[The Swift Programming Language][tspl]*.
734+
/// see [Concurrency][concurrency] in [The Swift Programming Language][tspl].
735735
///
736736
/// [concurrency]: https://docs.swift.org/swift-book/LanguageGuide/Concurrency.html
737737
/// [tspl]: https://docs.swift.org/swift-book/
@@ -878,8 +878,8 @@ func _getCurrentThreadPriority() -> Int
878878

879879
#if _runtime(_ObjC)
880880

881-
/// Intrinsic used by SILGen to launch a task for bridging a Swift async method
882-
/// which was called through its ObjC-exported completion-handler-based API.
881+
/// Intrinsic used by SILGen<!-- FIXME: Should this be in code font? --> to launch a task for bridging a Swift async method
882+
/// which was called through its ObjC<!-- FIXME: Should this be in code font? -->-exported completion-handlerbased API.
883883
@available(SwiftStdlib 5.5, *)
884884
@_alwaysEmitIntoClient
885885
@usableFromInline

stdlib/public/Concurrency/TaskCancellation.swift

Lines changed: 11 additions & 11 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.
19+
/// invoked if the current task is canceled<!-- FIXME: Passive; rewrite. -->.
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. For example, even if the
23+
/// _immediately_ invoked when the task is canceled<!-- FIXME: Passive; rewrite. -->. 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
///
@@ -34,8 +34,8 @@ public func withTaskCancellationHandler<T>(
3434
) async rethrows -> T {
3535
let task = Builtin.getCurrentAsyncTask()
3636

37-
// unconditionally add the cancellation record to the task.
38-
// if the task was already cancelled, it will be executed right away.
37+
// Unconditionally add the cancellation record to the task.
38+
// If the task was already canceled, it executes immediately.
3939
let record = _taskAddCancellationHandler(handler: handler)
4040
defer { _taskRemoveCancellationHandler(record: record) }
4141

@@ -44,7 +44,7 @@ public func withTaskCancellationHandler<T>(
4444

4545
@available(SwiftStdlib 5.5, *)
4646
extension Task {
47-
/// Returns `true` if the task is canceled, and should stop executing.
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.
4848
///
4949
/// - SeeAlso: `checkCancellation()`
5050
public var isCancelled: Bool {
@@ -60,10 +60,10 @@ extension Task {
6060

6161
@available(SwiftStdlib 5.5, *)
6262
extension Task where Success == Never, Failure == Never {
63-
/// Returns `true` if the task is canceled, and should stop executing.
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? -->
6464
///
6565
/// If no current `Task` is available, returns `false`, as outside of a task
66-
/// context no task cancellation may be observed.
66+
/// context no task cancellation may be observed<!-- FIXME: Passive; rewrite. -->.
6767
///
6868
/// - SeeAlso: `checkCancellation()`
6969
public static var isCancelled: Bool {
@@ -75,7 +75,7 @@ extension Task where Success == Never, Failure == Never {
7575

7676
@available(SwiftStdlib 5.5, *)
7777
extension Task where Success == Never, Failure == Never {
78-
/// Check if the task is canceled and throw an `CancellationError` if it was.
78+
/// Check if the task is canceled<!-- FIXME: Passive; rewrite. --> and throw an `CancellationError`<!-- FIXME: Don't include symbols in abstracts. --> if it was.
7979
///
8080
/// The error is always an instance of `Task.CancellationError`.
8181
///
@@ -87,13 +87,13 @@ extension Task where Success == Never, Failure == Never {
8787
}
8888
}
8989

90-
/// The default cancellation thrown when a task is canceled.
90+
/// The default cancellation thrown when a task is canceled<!-- FIXME: Passive; rewrite. -->.
9191
///
9292
/// This error is also thrown automatically by `Task.checkCancellation()`,
93-
/// if the current task has been canceled.
93+
/// if the current task has been canceled<!-- FIXME: Passive; rewrite. -->.
9494
@available(SwiftStdlib 5.5, *)
9595
public struct CancellationError: Error {
96-
// no extra information, cancellation is intended to be light-weight
96+
// No extra information; cancellation is intended to be light-weight.
9797
public init() {}
9898
}
9999

0 commit comments

Comments
 (0)