1
- ![ stable ( feature = "futures_api" , since = "1.36.0" ) ]
1
+ # ![ stable( feature = "futures_api" , since = "1.36.0" ) ]
2
2
3
3
use core:: fmt;
4
4
use core:: marker:: { PhantomData , Unpin } ;
@@ -11,7 +11,7 @@ use core::marker::{PhantomData, Unpin};
11
11
/// It consists of a data pointer and a [virtual function pointer table (vtable)][vtable]
12
12
/// that customizes the behavior of the `RawWaker`.
13
13
#[ derive( PartialEq , Debug ) ]
14
- [ stable ( feature = "futures_api" , since = "1.36.0" ) ]
14
+ # [ stable( feature = "futures_api" , since = "1.36.0" ) ]
15
15
#[ repr( C ) ]
16
16
pub struct RawWaker {
17
17
/// A data pointer, which can be used to store arbitrary data as required
@@ -37,9 +37,9 @@ impl RawWaker {
37
37
/// from a `RawWaker`. For each operation on the `Waker`, the associated
38
38
/// function in the `vtable` of the underlying `RawWaker` will be called.
39
39
#[ inline]
40
- [ rustc_promotable]
41
- [ stable ( feature = "futures_api" , since = "1.36.0" ) ]
42
- [ rustc_const_stable ( feature = "futures_api" , since = "1.36.0" ) ]
40
+ # [ rustc_promotable]
41
+ # [ stable( feature = "futures_api" , since = "1.36.0" ) ]
42
+ # [ rustc_const_stable( feature = "futures_api" , since = "1.36.0" ) ]
43
43
#[ must_use]
44
44
pub const fn new ( data : * const ( ) , vtable : & ' static RawWakerVTable ) -> RawWaker {
45
45
RawWaker { data, vtable }
@@ -48,15 +48,15 @@ impl RawWaker {
48
48
/// Get the `data` pointer used to create this `RawWaker`.
49
49
#[ inline]
50
50
#[ must_use]
51
- [ unstable ( feature = "waker_getters" , issue = "87021" ) ]
51
+ # [ unstable( feature = "waker_getters" , issue = "87021" ) ]
52
52
pub fn data ( & self ) -> * const ( ) {
53
53
self . data
54
54
}
55
55
56
56
/// Get the `vtable` pointer used to create this `RawWaker`.
57
57
#[ inline]
58
58
#[ must_use]
59
- [ unstable ( feature = "waker_getters" , issue = "87021" ) ]
59
+ # [ unstable( feature = "waker_getters" , issue = "87021" ) ]
60
60
pub fn vtable ( & self ) -> & ' static RawWakerVTable {
61
61
self . vtable
62
62
}
@@ -80,7 +80,7 @@ const RAW_WAKER_VTABLE_V1_PADDING: usize = 0;
80
80
/// because [`Waker`] is <code>[Send] + [Sync]</code>, and thus wakers may be moved to
81
81
/// arbitrary threads or invoked by `&` reference. For example, this means that if the
82
82
/// `clone` and `drop` functions manage a reference count, they must do so atomically.
83
- [ stable ( feature = "futures_api" , since = "1.36.0" ) ]
83
+ # [ stable( feature = "futures_api" , since = "1.36.0" ) ]
84
84
#[ derive( PartialEq , Copy , Clone , Debug ) ]
85
85
#[ repr( C ) ]
86
86
struct RawWakerVTableV1 {
@@ -192,7 +192,7 @@ impl RawWakerVTable {
192
192
/// arbitrary threads or invoked by `&` reference. For example, this means that if the
193
193
/// `clone` and `drop` functions manage a reference count, they must do so atomically.
194
194
///
195
- / `clone`
195
+ /# `clone`
196
196
///
197
197
/// This function will be called when the [`RawWaker`] gets cloned, e.g. when
198
198
/// the [`Waker`] in which the [`RawWaker`] is stored gets cloned.
@@ -202,7 +202,7 @@ impl RawWakerVTable {
202
202
/// task. Calling `wake` on the resulting [`RawWaker`] should result in a wakeup
203
203
/// of the same task that would have been awoken by the original [`RawWaker`].
204
204
///
205
- / `wake`
205
+ /# `wake`
206
206
///
207
207
/// This function will be called when `wake` is called on the [`Waker`].
208
208
/// It must wake up the task associated with this [`RawWaker`].
@@ -211,24 +211,24 @@ impl RawWakerVTable {
211
211
/// resources that are associated with this instance of a [`RawWaker`] and
212
212
/// associated task.
213
213
///
214
- / `wake_by_ref`
214
+ /# `wake_by_ref`
215
215
///
216
216
/// This function will be called when `wake_by_ref` is called on the [`Waker`].
217
217
/// It must wake up the task associated with this [`RawWaker`].
218
218
///
219
219
/// This function is similar to `wake`, but must not consume the provided data
220
220
/// pointer.
221
221
///
222
- / `drop`
222
+ /# `drop`
223
223
///
224
224
/// This function gets called when a [`Waker`] gets dropped.
225
225
///
226
226
/// The implementation of this function must make sure to release any
227
227
/// resources that are associated with this instance of a [`RawWaker`] and
228
228
/// associated task.
229
- [ rustc_promotable]
230
- [ stable( feature = "futures_api", since = "1 . 36 . 0 ") ]
231
- [ rustc_const_stable( feature = "futures_api", since = "1 . 36 . 0 ") ]
229
+ # [ rustc_promotable]
230
+ # [ stable( feature = "futures_api" , since = "1.36.0" ) ]
231
+ # [ rustc_const_stable( feature = "futures_api" , since = "1.36.0" ) ]
232
232
#[ deprecated = "This constructor makes slower wakers, use new_with_c_abi instead" ]
233
233
pub const fn new (
234
234
clone : unsafe fn ( * const ( ) ) -> RawWaker ,
@@ -267,7 +267,7 @@ impl RawWakerVTable {
267
267
/// arbitrary threads or invoked by `&` reference. For example, this means that if the
268
268
/// `clone` and `drop` functions manage a reference count, they must do so atomically.
269
269
///
270
- / `clone`
270
+ /# `clone`
271
271
///
272
272
/// This function will be called when the [`RawWaker`] gets cloned, e.g. when
273
273
/// the [`Waker`] in which the [`RawWaker`] is stored gets cloned.
@@ -277,7 +277,7 @@ impl RawWakerVTable {
277
277
/// task. Calling `wake` on the resulting [`RawWaker`] should result in a wakeup
278
278
/// of the same task that would have been awoken by the original [`RawWaker`].
279
279
///
280
- / `wake`
280
+ /# `wake`
281
281
///
282
282
/// This function will be called when `wake` is called on the [`Waker`].
283
283
/// It must wake up the task associated with this [`RawWaker`].
@@ -286,22 +286,22 @@ impl RawWakerVTable {
286
286
/// resources that are associated with this instance of a [`RawWaker`] and
287
287
/// associated task.
288
288
///
289
- / `wake_by_ref`
289
+ /# `wake_by_ref`
290
290
///
291
291
/// This function will be called when `wake_by_ref` is called on the [`Waker`].
292
292
/// It must wake up the task associated with this [`RawWaker`].
293
293
///
294
294
/// This function is similar to `wake`, but must not consume the provided data
295
295
/// pointer.
296
296
///
297
- / `drop`
297
+ /# `drop`
298
298
///
299
299
/// This function gets called when a [`Waker`] gets dropped.
300
300
///
301
301
/// The implementation of this function must make sure to release any
302
302
/// resources that are associated with this instance of a [`RawWaker`] and
303
303
/// associated task.
304
- [ rustc_promotable]
304
+ # [ rustc_promotable]
305
305
pub const fn new_with_c_abi (
306
306
clone : unsafe extern "C" fn ( * const ( ) ) -> RawWaker ,
307
307
wake : unsafe extern "C" fn ( * const ( ) ) ,
@@ -324,8 +324,8 @@ impl RawWakerVTable {
324
324
///
325
325
/// Currently, `Context` only serves to provide access to a [`&Waker`](Waker)
326
326
/// which can be used to wake the current task.
327
- [ stable ( feature = "futures_api" , since = "1.36.0" ) ]
328
- [ lang = "Context" ]
327
+ # [ stable( feature = "futures_api" , since = "1.36.0" ) ]
328
+ # [ lang = "Context" ]
329
329
pub struct Context < ' a > {
330
330
waker : & ' a Waker ,
331
331
// Ensure we future-proof against variance changes by forcing
@@ -340,8 +340,8 @@ pub struct Context<'a> {
340
340
341
341
impl < ' a > Context < ' a > {
342
342
/// Create a new `Context` from a [`&Waker`](Waker).
343
- [ stable ( feature = "futures_api" , since = "1.36.0" ) ]
344
- [ rustc_const_unstable ( feature = "const_waker" , issue = "102012" ) ]
343
+ # [ stable( feature = "futures_api" , since = "1.36.0" ) ]
344
+ # [ rustc_const_unstable( feature = "const_waker" , issue = "102012" ) ]
345
345
#[ must_use]
346
346
#[ inline]
347
347
pub const fn from_waker ( waker : & ' a Waker ) -> Self {
@@ -353,16 +353,16 @@ impl<'a> Context<'a> {
353
353
}
354
354
355
355
/// Returns a reference to the [`Waker`] for the current task.
356
- [ stable ( feature = "futures_api" , since = "1.36.0" ) ]
357
- [ rustc_const_unstable ( feature = "const_waker" , issue = "102012" ) ]
356
+ # [ stable( feature = "futures_api" , since = "1.36.0" ) ]
357
+ # [ rustc_const_unstable( feature = "const_waker" , issue = "102012" ) ]
358
358
#[ must_use]
359
359
#[ inline]
360
360
pub const fn waker ( & self ) -> & ' a Waker {
361
361
self . waker
362
362
}
363
363
}
364
364
365
- [ stable ( feature = "futures_api" , since = "1.36.0" ) ]
365
+ # [ stable( feature = "futures_api" , since = "1.36.0" ) ]
366
366
impl fmt:: Debug for Context < ' _ > {
367
367
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
368
368
f. debug_struct ( "Context" )
@@ -390,16 +390,16 @@ impl fmt::Debug for Context<'_> {
390
390
/// [`Future::poll()`]: core::future::Future::poll
391
391
/// [`Poll::Pending`]: core::task::Poll::Pending
392
392
#[ repr( transparent) ]
393
- [ stable ( feature = "futures_api" , since = "1.36.0" ) ]
393
+ # [ stable( feature = "futures_api" , since = "1.36.0" ) ]
394
394
pub struct Waker {
395
395
waker : RawWaker ,
396
396
}
397
397
398
- [ stable ( feature = "futures_api" , since = "1.36.0" ) ]
398
+ # [ stable( feature = "futures_api" , since = "1.36.0" ) ]
399
399
impl Unpin for Waker { }
400
- [ stable ( feature = "futures_api" , since = "1.36.0" ) ]
400
+ # [ stable( feature = "futures_api" , since = "1.36.0" ) ]
401
401
unsafe impl Send for Waker { }
402
- [ stable ( feature = "futures_api" , since = "1.36.0" ) ]
402
+ # [ stable( feature = "futures_api" , since = "1.36.0" ) ]
403
403
unsafe impl Sync for Waker { }
404
404
405
405
impl Waker {
@@ -421,7 +421,7 @@ impl Waker {
421
421
///
422
422
/// [`poll()`]: core::future::Future::poll
423
423
#[ inline]
424
- [ stable ( feature = "futures_api" , since = "1.36.0" ) ]
424
+ # [ stable( feature = "futures_api" , since = "1.36.0" ) ]
425
425
pub fn wake ( self ) {
426
426
// The actual wakeup call is delegated through a virtual function call
427
427
// to the implementation which is defined by the executor.
@@ -457,7 +457,7 @@ impl Waker {
457
457
/// the case where an owned `Waker` is available. This method should be preferred to
458
458
/// calling `waker.clone().wake()`.
459
459
#[ inline]
460
- [ stable ( feature = "futures_api" , since = "1.36.0" ) ]
460
+ # [ stable( feature = "futures_api" , since = "1.36.0" ) ]
461
461
pub fn wake_by_ref ( & self ) {
462
462
// The actual wakeup call is delegated through a virtual function call
463
463
// to the implementation which is defined by the executor.
@@ -490,7 +490,7 @@ impl Waker {
490
490
/// This function is primarily used for optimization purposes.
491
491
#[ inline]
492
492
#[ must_use]
493
- [ stable ( feature = "futures_api" , since = "1.36.0" ) ]
493
+ # [ stable( feature = "futures_api" , since = "1.36.0" ) ]
494
494
pub fn will_wake ( & self , other : & Waker ) -> bool {
495
495
self . waker == other. waker
496
496
}
@@ -502,22 +502,22 @@ impl Waker {
502
502
/// Therefore this method is unsafe.
503
503
#[ inline]
504
504
#[ must_use]
505
- [ stable ( feature = "futures_api" , since = "1.36.0" ) ]
506
- [ rustc_const_unstable ( feature = "const_waker" , issue = "102012" ) ]
505
+ # [ stable( feature = "futures_api" , since = "1.36.0" ) ]
506
+ # [ rustc_const_unstable( feature = "const_waker" , issue = "102012" ) ]
507
507
pub const unsafe fn from_raw ( waker : RawWaker ) -> Waker {
508
508
Waker { waker }
509
509
}
510
510
511
511
/// Get a reference to the underlying [`RawWaker`].
512
512
#[ inline]
513
513
#[ must_use]
514
- [ unstable ( feature = "waker_getters" , issue = "87021" ) ]
514
+ # [ unstable( feature = "waker_getters" , issue = "87021" ) ]
515
515
pub fn as_raw ( & self ) -> & RawWaker {
516
516
& self . waker
517
517
}
518
518
}
519
519
520
- [ stable ( feature = "futures_api" , since = "1.36.0" ) ]
520
+ # [ stable( feature = "futures_api" , since = "1.36.0" ) ]
521
521
impl Clone for Waker {
522
522
#[ inline]
523
523
fn clone ( & self ) -> Self {
@@ -545,7 +545,7 @@ impl Clone for Waker {
545
545
}
546
546
}
547
547
548
- [ stable ( feature = "futures_api" , since = "1.36.0" ) ]
548
+ # [ stable( feature = "futures_api" , since = "1.36.0" ) ]
549
549
impl Drop for Waker {
550
550
#[ inline]
551
551
fn drop ( & mut self ) {
@@ -571,7 +571,7 @@ impl Drop for Waker {
571
571
}
572
572
}
573
573
574
- [ stable ( feature = "futures_api" , since = "1.36.0" ) ]
574
+ # [ stable( feature = "futures_api" , since = "1.36.0" ) ]
575
575
impl fmt:: Debug for Waker {
576
576
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
577
577
let vtable_ptr = self . waker . vtable as * const RawWakerVTable ;
0 commit comments