mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-18 18:04:13 +00:00
fix: Apply suggestions from code review
Co-authored-by: Mark Rousskov <mark.simulacrum@gmail.com>
This commit is contained in:
parent
a8e71f2258
commit
c67a446e72
@ -168,14 +168,14 @@ fn raw_waker<W: Wake + Send + Sync + 'static>(waker: Arc<W>) -> RawWaker {
|
||||
/// to hold data that does not implement `Send` and `Sync`. Additionally, it saves calls
|
||||
/// to `Arc::clone`, which requires atomic synchronization.
|
||||
///
|
||||
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// This is a simplified example of a `spawn` and a `block_on` function. The `spawn` function
|
||||
/// is used to push new tasks onto the run queue, while the block on function will remove them
|
||||
/// and poll them. When a task is woken, it will put itself back on the run queue to be polled by the executor.
|
||||
///
|
||||
/// **Note:** A real world example would interlieve poll calls with calls to an io reactor to wait for events instead
|
||||
/// **Note:** A real world example would interleave poll calls with calls to an io reactor to wait for events instead
|
||||
/// of spinning on a loop.
|
||||
///
|
||||
/// ```rust
|
||||
@ -221,7 +221,7 @@ fn raw_waker<W: Wake + Send + Sync + 'static>(waker: Arc<W>) -> RawWaker {
|
||||
/// {
|
||||
/// spawn(future);
|
||||
/// loop {
|
||||
/// let Some(task) = RUN_QUEUE.with_borrow_mut(|queue|queue.pop_front()) else {
|
||||
/// let Some(task) = RUN_QUEUE.with_borrow_mut(|queue| queue.pop_front()) else {
|
||||
/// // we exit, since there are no more tasks remaining on the queue
|
||||
/// return;
|
||||
/// };
|
||||
|
@ -332,7 +332,6 @@ impl<'a> ContextBuilder<'a> {
|
||||
}
|
||||
|
||||
/// This field is used to set the value of the waker on `Context`.
|
||||
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "const_waker", issue = "102012")]
|
||||
#[unstable(feature = "local_waker", issue = "118959")]
|
||||
@ -598,6 +597,7 @@ impl fmt::Debug for Waker {
|
||||
}
|
||||
|
||||
/// A `LocalWaker` is analogous to a [`Waker`], but it does not implement [`Send`] or [`Sync`].
|
||||
///
|
||||
/// This handle encapsulates a [`RawWaker`] instance, which defines the
|
||||
/// executor-specific wakeup behavior.
|
||||
///
|
||||
@ -646,9 +646,8 @@ impl fmt::Debug for Waker {
|
||||
/// [`Future::poll()`]: core::future::Future::poll
|
||||
/// [`Poll::Pending`]: core::task::Poll::Pending
|
||||
/// [`local_waker`]: core::task::Context::local_waker
|
||||
|
||||
#[unstable(feature = "local_waker", issue = "118959")]
|
||||
#[repr(transparent)]
|
||||
#[cfg_attr(not(doc), repr(transparent))] // work around https://github.com/rust-lang/rust/issues/66401
|
||||
pub struct LocalWaker {
|
||||
waker: RawWaker,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user