@@ -2,18 +2,18 @@ import Foundation
22
33/// An object that controls cooperative cancellation of multiple registered tasks and linked object registered tasks.
44///
5- /// An async event suspends tasks if current state is non-signaled and resumes execution when event is signaled .
5+ /// An async event suspends tasks if current state is non-signaled and resumes execution when event is signalled .
66///
77/// You can register tasks for cancellation using the ``register(task:)`` method
88/// and link with additional sources by creating object with ``init(linkedWith:)`` method.
9- /// By calling the ``cancel()`` method all the reigistered tasks will be cancelled
9+ /// By calling the ``cancel()`` method all the registered tasks will be cancelled
1010/// and the cancellation event will be propagated to linked cancellation sources,
11- /// which in turn cancels their rigistered tasks and further propagates cancellation.
11+ /// which in turn cancels their registered tasks and further propagates cancellation.
1212///
1313/// - Warning: Cancellation sources propagate cancellation event to other linked cancellation sources.
1414/// In case of circular dependency between cancellation sources, app will go into infinite recursion.
1515public actor CancellationSource {
16- /// All the rigistered tasks for cooperative cancellation.
16+ /// All the registered tasks for cooperative cancellation.
1717 private var registeredTasks : [ AnyHashable : ( ) -> Void ] = [ : ]
1818 /// All the linked cancellation sources that cancellation event will be propagated.
1919 ///
@@ -27,7 +27,7 @@ public actor CancellationSource {
2727 ///
2828 /// - Parameter task: The task to register.
2929 @inline ( __always)
30- private func add< Success, Faliure > ( task: Task < Success , Faliure > ) {
30+ private func add< Success, Failure > ( task: Task < Success , Failure > ) {
3131 guard !task. isCancelled else { return }
3232 registeredTasks [ task] = { task. cancel ( ) }
3333 }
@@ -36,7 +36,7 @@ public actor CancellationSource {
3636 ///
3737 /// - Parameter task: The task to remove.
3838 @inline ( __always)
39- private func remove< Success, Faliure > ( task: Task < Success , Faliure > ) {
39+ private func remove< Success, Failure > ( task: Task < Success , Failure > ) {
4040 registeredTasks. removeValue ( forKey: task)
4141 }
4242
@@ -56,7 +56,7 @@ public actor CancellationSource {
5656 /// Creates a new cancellation source object linking to all the provided cancellation sources.
5757 ///
5858 /// Initiating cancellation in any of the provided cancellation sources
59- /// will ensure newly created cancellation source recieve cancellation event.
59+ /// will ensure newly created cancellation source receive cancellation event.
6060 ///
6161 /// - Parameter sources: The cancellation sources the newly created object will be linked to.
6262 ///
@@ -73,7 +73,7 @@ public actor CancellationSource {
7373 /// Creates a new cancellation source object linking to all the provided cancellation sources.
7474 ///
7575 /// Initiating cancellation in any of the provided cancellation sources
76- /// will ensure newly created cancellation source recieve cancellation event.
76+ /// will ensure newly created cancellation source receive cancellation event.
7777 ///
7878 /// - Parameter sources: The cancellation sources the newly created object will be linked to.
7979 ///
@@ -95,13 +95,13 @@ public actor CancellationSource {
9595 }
9696 }
9797
98- /// Register task for cooperative cancellation when cancellation event recieved on cancellation source.
98+ /// Register task for cooperative cancellation when cancellation event received on cancellation source.
9999 ///
100100 /// If task completes before cancellation event is triggered, it is automatically unregistered.
101101 ///
102102 /// - Parameter task: The task to register.
103103 @Sendable
104- public func register< Success, Faliure > ( task: Task < Success , Faliure > ) {
104+ public func register< Success, Failure > ( task: Task < Success , Failure > ) {
105105 add ( task: task)
106106 Task { [ weak self] in
107107 let _ = await task. result
@@ -134,7 +134,7 @@ public actor CancellationSource {
134134}
135135
136136public extension Task {
137- /// Runs the given nonthrowing operation asynchronously as part of a new task on behalf of the current actor,
137+ /// Runs the given non-throwing operation asynchronously as part of a new task on behalf of the current actor,
138138 /// with the provided cancellation source controlling cooperative cancellation.
139139 ///
140140 /// A child task with the provided operation is created, cancellation of which is controlled by provided cancellation source.
@@ -186,7 +186,7 @@ public extension Task {
186186 }
187187 }
188188
189- /// Runs the given nonthrowing operation asynchronously as part of a new task,
189+ /// Runs the given non-throwing operation asynchronously as part of a new task,
190190 /// with the provided cancellation source controlling cooperative cancellation.
191191 ///
192192 /// A child task with the provided operation is created, cancellation of which is controlled by provided cancellation source.
@@ -238,7 +238,7 @@ public extension Task {
238238 }
239239 }
240240
241- /// Runs the given nonthrowing operation asynchronously as part of a new top-level task on behalf of the current actor,
241+ /// Runs the given non-throwing operation asynchronously as part of a new top-level task on behalf of the current actor,
242242 /// with the provided cancellation source controlling cooperative cancellation.
243243 ///
244244 /// The created task will be cancelled when cancellation event triggered on the provided cancellation source.
@@ -280,7 +280,7 @@ public extension Task {
280280 await cancellationSource. register ( task: self )
281281 }
282282
283- /// Runs the given nonthrowing operation asynchronously as part of a new top-level task,
283+ /// Runs the given non-throwing operation asynchronously as part of a new top-level task,
284284 /// with the provided cancellation source controlling cooperative cancellation.
285285 ///
286286 /// The created task will be cancelled when cancellation event triggered on the provided cancellation source.
0 commit comments