|
1 | 1 | #![feature(never_type)] |
| 2 | +#![feature(wake_trait)] |
2 | 3 |
|
3 | | -use std::{future::Future, pin::Pin, task::Poll, ptr}; |
4 | | -use std::task::{Waker, RawWaker, RawWakerVTable, Context}; |
| 4 | +use std::{future::Future, pin::Pin, task::Poll}; |
| 5 | +use std::task::{Wake, Waker, Context}; |
| 6 | +use std::sync::Arc; |
5 | 7 |
|
6 | 8 | // See if we can run a basic `async fn` |
7 | 9 | pub async fn foo(x: &u32, y: u32) -> u32 { |
@@ -47,25 +49,14 @@ async fn partial_init(x: u32) -> u32 { |
47 | 49 | } |
48 | 50 |
|
49 | 51 | fn run_fut(mut fut: impl Future<Output=u32>, output: u32) { |
50 | | - fn raw_waker_clone(_this: *const ()) -> RawWaker { |
51 | | - panic!("unimplemented"); |
| 52 | + struct MyWaker; |
| 53 | + impl Wake for MyWaker { |
| 54 | + fn wake(self: Arc<Self>) { |
| 55 | + unimplemented!() |
| 56 | + } |
52 | 57 | } |
53 | | - fn raw_waker_wake(_this: *const ()) { |
54 | | - panic!("unimplemented"); |
55 | | - } |
56 | | - fn raw_waker_wake_by_ref(_this: *const ()) { |
57 | | - panic!("unimplemented"); |
58 | | - } |
59 | | - fn raw_waker_drop(_this: *const ()) {} |
60 | | - |
61 | | - static RAW_WAKER: RawWakerVTable = RawWakerVTable::new( |
62 | | - raw_waker_clone, |
63 | | - raw_waker_wake, |
64 | | - raw_waker_wake_by_ref, |
65 | | - raw_waker_drop, |
66 | | - ); |
67 | 58 |
|
68 | | - let waker = unsafe { Waker::from_raw(RawWaker::new(ptr::null(), &RAW_WAKER)) }; |
| 59 | + let waker = Waker::from(Arc::new(MyWaker)); |
69 | 60 | let mut context = Context::from_waker(&waker); |
70 | 61 | assert_eq!(unsafe { Pin::new_unchecked(&mut fut) }.poll(&mut context), Poll::Ready(output)); |
71 | 62 | } |
|
0 commit comments