Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 0cb7a0a

Browse files
committed
chore: add tracking issue number to local waker feature
1 parent 2012d4b commit 0cb7a0a

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed

library/alloc/src/task.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@
33
//! Types and Traits for working with asynchronous tasks.
44
//!
55
//! **Note**: Some of the types in this module are only available
6-
//! on platforms that support atomic loads and stores of pointers.
7-
//! This may be detected at compile time using
6+
//! on platforms that support atomic loads and stores of pointers.
7+
//! This may be detected at compile time using
88
//! `#[cfg(target_has_atomic = "ptr")]`.
99
10+
use crate::rc::Rc;
1011
use core::mem::ManuallyDrop;
1112
use core::task::{LocalWaker, RawWaker, RawWakerVTable};
12-
use crate::rc::Rc;
1313

1414
#[cfg(target_has_atomic = "ptr")]
15-
use core::{task::Waker, sync::Arc};
15+
use crate::sync::Arc;
16+
#[cfg(target_has_atomic = "ptr")]
17+
use core::task::Waker;
1618

1719
/// The implementation of waking a task on an executor.
1820
///
@@ -174,7 +176,7 @@ fn raw_waker<W: Wake + Send + Sync + 'static>(waker: Arc<W>) -> RawWaker {
174176
/// and poll them. When a task is woken, it will put itself back on the run queue to be polled by the executor.
175177
///
176178
/// **Note:** A real world example would interlieve poll calls with calls to an io reactor to wait for events instead
177-
/// of spinning on a loop.
179+
/// of spinning on a loop.
178180
///
179181
/// ```rust
180182
/// #![feature(local_waker)]
@@ -242,10 +244,10 @@ fn raw_waker<W: Wake + Send + Sync + 'static>(waker: Arc<W>) -> RawWaker {
242244
/// });
243245
/// ```
244246
///
245-
#[unstable(feature = "local_waker", issue = "none")]
247+
#[unstable(feature = "local_waker", issue = "118959")]
246248
pub trait LocalWake {
247249
/// Wake this task.
248-
#[unstable(feature = "local_waker", issue = "none")]
250+
#[unstable(feature = "local_waker", issue = "118959")]
249251
fn wake(self: Rc<Self>);
250252

251253
/// Wake this task without consuming the local waker.
@@ -255,13 +257,13 @@ pub trait LocalWake {
255257
/// [`Rc`] and calls [`wake`] on the clone.
256258
///
257259
/// [`wake`]: Rc::wake
258-
#[unstable(feature = "local_waker", issue = "none")]
260+
#[unstable(feature = "local_waker", issue = "118959")]
259261
fn wake_by_ref(self: &Rc<Self>) {
260262
self.clone().wake();
261263
}
262264
}
263265

264-
#[unstable(feature = "local_waker", issue = "none")]
266+
#[unstable(feature = "local_waker", issue = "118959")]
265267
impl<W: LocalWake + 'static> From<Rc<W>> for LocalWaker {
266268
/// Use a `Wake`-able type as a `LocalWaker`.
267269
///
@@ -273,7 +275,7 @@ impl<W: LocalWake + 'static> From<Rc<W>> for LocalWaker {
273275
}
274276
}
275277
#[allow(ineffective_unstable_trait_impl)]
276-
#[unstable(feature = "local_waker", issue = "none")]
278+
#[unstable(feature = "local_waker", issue = "118959")]
277279
impl<W: LocalWake + 'static> From<Rc<W>> for RawWaker {
278280
/// Use a `Wake`-able type as a `RawWaker`.
279281
///

library/core/src/task/wake.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ impl<'a> Context<'a> {
238238
}
239239
/// Returns a reference to the [`LocalWaker`] for the current task.
240240
#[inline]
241-
#[unstable(feature = "local_waker", issue = "none")]
241+
#[unstable(feature = "local_waker", issue = "118959")]
242242
#[rustc_const_unstable(feature = "const_waker", issue = "102012")]
243243
pub const fn local_waker(&self) -> &'a LocalWaker {
244244
&self.local_waker
@@ -247,7 +247,7 @@ impl<'a> Context<'a> {
247247
/// otherwise it returns `None`.
248248
#[inline]
249249
#[rustc_const_unstable(feature = "const_waker", issue = "102012")]
250-
#[unstable(feature = "local_waker", issue = "none")]
250+
#[unstable(feature = "local_waker", issue = "118959")]
251251
pub const fn try_waker(&self) -> Option<&'a Waker> {
252252
self.waker
253253
}
@@ -282,7 +282,7 @@ impl fmt::Debug for Context<'_> {
282282
/// assert_eq!(poll, Poll::Ready(20));
283283
///
284284
/// ```
285-
#[unstable(feature = "local_waker", issue = "none")]
285+
#[unstable(feature = "local_waker", issue = "118959")]
286286
#[derive(Debug)]
287287
pub struct ContextBuilder<'a> {
288288
waker: Option<&'a Waker>,
@@ -293,7 +293,7 @@ impl<'a> ContextBuilder<'a> {
293293
/// Create a ContextBuilder from a Waker.
294294
#[inline]
295295
#[rustc_const_unstable(feature = "const_waker", issue = "102012")]
296-
#[unstable(feature = "local_waker", issue = "none")]
296+
#[unstable(feature = "local_waker", issue = "118959")]
297297
pub const fn from_waker(waker: &'a Waker) -> Self {
298298
// SAFETY: LocalWaker is just Waker without thread safety
299299
let local_waker = unsafe { transmute(waker) };
@@ -303,7 +303,7 @@ impl<'a> ContextBuilder<'a> {
303303
/// Create a ContextBuilder from a LocalWaker.
304304
#[inline]
305305
#[rustc_const_unstable(feature = "const_waker", issue = "102012")]
306-
#[unstable(feature = "local_waker", issue = "none")]
306+
#[unstable(feature = "local_waker", issue = "118959")]
307307
pub const fn from_local_waker(local_waker: &'a LocalWaker) -> Self {
308308
Self { local_waker, waker: None }
309309
}
@@ -312,22 +312,22 @@ impl<'a> ContextBuilder<'a> {
312312
313313
#[inline]
314314
#[rustc_const_unstable(feature = "const_waker", issue = "102012")]
315-
#[unstable(feature = "local_waker", issue = "none")]
315+
#[unstable(feature = "local_waker", issue = "118959")]
316316
pub const fn waker(self, waker: &'a Waker) -> Self {
317317
Self { waker: Some(waker), ..self }
318318
}
319319

320320
/// This method is used to set the value for the local waker on `Context`.
321321
#[inline]
322-
#[unstable(feature = "local_waker", issue = "none")]
322+
#[unstable(feature = "local_waker", issue = "118959")]
323323
#[rustc_const_unstable(feature = "const_waker", issue = "102012")]
324324
pub const fn local_waker(self, local_waker: &'a LocalWaker) -> Self {
325325
Self { local_waker, ..self }
326326
}
327327

328328
/// Builds the `Context`.
329329
#[inline]
330-
#[unstable(feature = "local_waker", issue = "none")]
330+
#[unstable(feature = "local_waker", issue = "118959")]
331331
#[rustc_const_unstable(feature = "const_waker", issue = "102012")]
332332
pub const fn build(self) -> Context<'a> {
333333
let ContextBuilder { waker, local_waker } = self;
@@ -370,7 +370,7 @@ impl<'a> ContextBuilder<'a> {
370370
/// with_waker(async { /* ... */ }, &Waker::noop()).await;
371371
/// # }
372372
/// ```
373-
#[unstable(feature = "local_waker", issue = "none")]
373+
#[unstable(feature = "local_waker", issue = "118959")]
374374
impl<'a> From<&mut Context<'a>> for ContextBuilder<'a> {
375375
#[inline]
376376
fn from(value: &mut Context<'a>) -> Self {
@@ -623,19 +623,19 @@ impl fmt::Debug for Waker {
623623
/// [`Future::poll()`]: core::future::Future::poll
624624
/// [`Poll::Pending`]: core::task::Poll::Pending
625625
/// [`local_waker`]: core::task::Context::local_waker
626-
#[unstable(feature = "local_waker", issue = "none")]
626+
#[unstable(feature = "local_waker", issue = "118959")]
627627
#[repr(transparent)]
628628
pub struct LocalWaker {
629629
waker: RawWaker,
630630
}
631631

632-
#[unstable(feature = "local_waker", issue = "none")]
632+
#[unstable(feature = "local_waker", issue = "118959")]
633633
impl Unpin for LocalWaker {}
634634

635635
impl LocalWaker {
636636
/// Creates a new `LocalWaker` from [`RawWaker`].
637637
///
638-
/// The behavior of the returned `Waker` is undefined if the contract defined
638+
/// The behavior of the returned `LocalWaker` is undefined if the contract defined
639639
/// in [`RawWaker`]'s and [`RawWakerVTable`]'s documentation is not upheld.
640640
/// Therefore this method is unsafe.
641641
#[inline]
@@ -651,7 +651,7 @@ impl LocalWaker {
651651
/// As long as the executor keeps running and the task is not finished, it is
652652
/// guaranteed that each invocation of [`wake()`](Self::wake) (or
653653
/// [`wake_by_ref()`](Self::wake_by_ref)) will be followed by at least one
654-
/// [`poll()`] of the task to which this `Waker` belongs. This makes
654+
/// [`poll()`] of the task to which this `LocalWaker` belongs. This makes
655655
/// it possible to temporarily yield to other tasks while running potentially
656656
/// unbounded processing loops.
657657
///
@@ -749,7 +749,7 @@ impl LocalWaker {
749749
unsafe { (self.waker.vtable.wake_by_ref)(self.waker.data) }
750750
}
751751
}
752-
#[unstable(feature = "local_waker", issue = "none")]
752+
#[unstable(feature = "local_waker", issue = "118959")]
753753
impl Clone for LocalWaker {
754754
#[inline]
755755
fn clone(&self) -> Self {

0 commit comments

Comments
 (0)