diff options
author | Stjepan Glavina <stjepang@gmail.com> | 2020-04-14 14:38:57 +0200 |
---|---|---|
committer | Stjepan Glavina <stjepang@gmail.com> | 2020-04-14 14:38:57 +0200 |
commit | d7b17fb5b004a877f13272d350c577b531486bdc (patch) | |
tree | a79947c8593c2d2c25374cc54555965b3690e0dc /src | |
parent | fad623a06dc0fef34149bb473db9dc31fa99b4d3 (diff) | |
download | async-task-d7b17fb5b004a877f13272d350c577b531486bdc.tar.gz |
Docs and grammar
Diffstat (limited to 'src')
-rw-r--r-- | src/header.rs | 2 | ||||
-rw-r--r-- | src/join_handle.rs | 6 | ||||
-rw-r--r-- | src/lib.rs | 9 | ||||
-rw-r--r-- | src/state.rs | 4 | ||||
-rw-r--r-- | src/task.rs | 12 |
5 files changed, 18 insertions, 15 deletions
diff --git a/src/header.rs b/src/header.rs index 5d808c7..a559e48 100644 --- a/src/header.rs +++ b/src/header.rs @@ -38,7 +38,7 @@ impl Header { let mut state = self.state.load(Ordering::Acquire); loop { - // If the task has been completed or closed, it can't be cancelled. + // If the task has been completed or closed, it can't be canceled. if state & (COMPLETED | CLOSED) != 0 { break; } diff --git a/src/join_handle.rs b/src/join_handle.rs index 10a189e..edf9fcd 100644 --- a/src/join_handle.rs +++ b/src/join_handle.rs @@ -13,7 +13,7 @@ use crate::state::*; /// /// This type is a future that resolves to an `Option<R>` where: /// -/// * `None` indicates the task has panicked or was cancelled. +/// * `None` indicates the task has panicked or was canceled. /// * `Some(result)` indicates the task has completed with `result` of type `R`. pub struct JoinHandle<R, T> { /// A raw task pointer. @@ -33,7 +33,7 @@ impl<R, T> JoinHandle<R, T> { /// /// If the task has already completed, calling this method will have no effect. /// - /// When a task is cancelled, its future will not be polled again. + /// When a task is canceled, its future will not be polled again. pub fn cancel(&self) { let ptr = self.raw_task.as_ptr(); let header = ptr as *const Header; @@ -42,7 +42,7 @@ impl<R, T> JoinHandle<R, T> { let mut state = (*header).state.load(Ordering::Acquire); loop { - // If the task has been completed or closed, it can't be cancelled. + // If the task has been completed or closed, it can't be canceled. if state & (COMPLETED | CLOSED) != 0 { break; } @@ -73,15 +73,18 @@ //! it's waiting for another future and needs to go to sleep. When woken up, its schedule function //! will be invoked, pushing it back into the queue so that it can be run again. //! -//! # Cancellation +//! # Cancelation //! -//! Both [`Task`] and [`JoinHandle`] have methods that cancel the task. When cancelled, the task's +//! Both [`Task`] and [`JoinHandle`] have methods that cancel the task. When canceled, the task's //! future will not be polled again and will get dropped instead. //! -//! If cancelled by the [`Task`] instance, the task is destroyed immediately. If cancelled by the +//! If canceled by the [`Task`] instance, the task is destroyed immediately. If canceled by the //! [`JoinHandle`] instance, it will be scheduled one more time and the next attempt to run it will //! simply destroy it. //! +//! The `JoinHandle` future will then evaluate to `None`, but only after the task's future is +//! dropped. +//! //! # Performance //! //! Task construction incurs a single allocation that holds its state, the schedule function, and diff --git a/src/state.rs b/src/state.rs index 167a371..58559ac 100644 --- a/src/state.rs +++ b/src/state.rs @@ -26,10 +26,10 @@ pub(crate) const COMPLETED: usize = 1 << 2; /// Set if the task is closed. /// -/// If a task is closed, that means it's either cancelled or its output has been consumed by the +/// If a task is closed, that means it's either canceled or its output has been consumed by the /// `JoinHandle`. A task becomes closed when: /// -/// 1. It gets cancelled by `Task::cancel()`, `Task::drop()`, or `JoinHandle::cancel()`. +/// 1. It gets canceled by `Task::cancel()`, `Task::drop()`, or `JoinHandle::cancel()`. /// 2. Its output gets awaited by the `JoinHandle`. /// 3. It panics while polling the future. /// 4. It is completed and the `JoinHandle` gets dropped. diff --git a/src/task.rs b/src/task.rs index d4da255..a300d63 100644 --- a/src/task.rs +++ b/src/task.rs @@ -180,8 +180,8 @@ where /// function. In most executors, scheduling simply pushes the [`Task`] reference into a queue of /// runnable tasks. /// -/// If the [`Task`] reference is dropped without getting run, the task is automatically cancelled. -/// When cancelled, the task won't be scheduled again even if a [`Waker`] wakes it. It is possible +/// If the [`Task`] reference is dropped without getting run, the task is automatically canceled. +/// When canceled, the task won't be scheduled again even if a [`Waker`] wakes it. It is possible /// for the [`JoinHandle`] to cancel while the [`Task`] reference exists, in which case an attempt /// to run the task won't do anything. /// @@ -206,7 +206,7 @@ impl<T> Task<T> { /// This is a convenience method that simply reschedules the task by passing it to its schedule /// function. /// - /// If the task is cancelled, this method won't do anything. + /// If the task is canceled, this method won't do anything. pub fn schedule(self) { let ptr = self.raw_task.as_ptr(); let header = ptr as *const Header; @@ -226,12 +226,12 @@ impl<T> Task<T> { /// available to the [`JoinHandle`]. And if the future is still pending, the task will have to /// be woken up in order to be rescheduled and run again. /// - /// If the task was cancelled by a [`JoinHandle`] before it gets run, then this method won't do + /// If the task was canceled by a [`JoinHandle`] before it gets run, then this method won't do /// anything. /// /// It is possible that polling the future panics, in which case the panic will be propagated /// into the caller. It is advised that invocations of this method are wrapped inside - /// [`catch_unwind`]. If a panic occurs, the task is automatically cancelled. + /// [`catch_unwind`]. If a panic occurs, the task is automatically canceled. /// /// [`JoinHandle`]: struct.JoinHandle.html /// [`catch_unwind`]: https://doc.rust-lang.org/std/panic/fn.catch_unwind.html @@ -245,7 +245,7 @@ impl<T> Task<T> { /// Cancels the task. /// - /// When cancelled, the task won't be scheduled again even if a [`Waker`] wakes it. An attempt + /// When canceled, the task won't be scheduled again even if a [`Waker`] wakes it. An attempt /// to run it won't do anything. /// /// [`Waker`]: https://doc.rust-lang.org/std/task/struct.Waker.html |