Skip to content

Commit ad8f3c4

Browse files
committed
Update to new futures_api (wake-by-ref)
1 parent 53af42c commit ad8f3c4

File tree

21 files changed

+75
-54
lines changed

21 files changed

+75
-54
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ matrix:
2525

2626
# When updating this, the reminder to update the minimum required version in README.md.
2727
- name: cargo test (minimum required version)
28-
rust: nightly-2019-04-08
28+
rust: nightly-2019-04-13
2929

3030
- name: cargo clippy
3131
rust: nightly

futures-core/src/task/__internal/atomic_waker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ impl AtomicWaker {
241241
// Currently in the process of waking the task, i.e.,
242242
// `wake` is currently being called on the old task handle.
243243
// So, we call wake on the new waker
244-
waker.wake();
244+
waker.wake_by_ref();
245245
}
246246
state => {
247247
// In this case, a concurrent thread is holding the

futures-executor/benches/thread_notify.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn thread_yield_single_thread_one_wait(b: &mut Bencher) {
2424
Poll::Ready(())
2525
} else {
2626
self.rem -= 1;
27-
cx.waker().wake();
27+
cx.waker().wake_by_ref();
2828
Poll::Pending
2929
}
3030
}
@@ -52,7 +52,7 @@ fn thread_yield_single_thread_many_wait(b: &mut Bencher) {
5252
Poll::Ready(())
5353
} else {
5454
self.rem -= 1;
55-
cx.waker().wake();
55+
cx.waker().wake_by_ref();
5656
Poll::Pending
5757
}
5858
}

futures-executor/src/local_pool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ thread_local! {
5050
}
5151

5252
impl ArcWake for ThreadNotify {
53-
fn wake(arc_self: &Arc<Self>) {
53+
fn wake_by_ref(arc_self: &Arc<Self>) {
5454
arc_self.thread.unpark();
5555
}
5656
}

futures-executor/src/thread_pool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ impl fmt::Debug for Task {
339339
}
340340

341341
impl ArcWake for WakeHandle {
342-
fn wake(arc_self: &Arc<Self>) {
342+
fn wake_by_ref(arc_self: &Arc<Self>) {
343343
match arc_self.mutex.notify() {
344344
Ok(task) => arc_self.exec.state.send(Message::Run(task)),
345345
Err(()) => {}

futures-executor/tests/local_pool.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ fn tasks_are_scheduled_fairly() {
147147
return Poll::Ready(());
148148
}
149149

150-
cx.waker().wake();
150+
cx.waker().wake_by_ref();
151151
Poll::Pending
152152
}
153153
}
@@ -167,4 +167,3 @@ fn tasks_are_scheduled_fairly() {
167167

168168
pool.run();
169169
}
170-

futures-io/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ mod if_std {
100100
///
101101
/// If no data is available for reading, the method returns
102102
/// `Ok(Poll::Pending)` and arranges for the current task (via
103-
/// `cx.waker().wake()`) to receive a notification when the object becomes
103+
/// `cx.waker().wake_by_ref()`) to receive a notification when the object becomes
104104
/// readable or is closed.
105105
///
106106
/// # Implementation
@@ -122,7 +122,7 @@ mod if_std {
122122
///
123123
/// If no data is available for reading, the method returns
124124
/// `Ok(Poll::Pending)` and arranges for the current task (via
125-
/// `cx.waker().wake()`) to receive a notification when the object becomes
125+
/// `cx.waker().wake_by_ref()`) to receive a notification when the object becomes
126126
/// readable or is closed.
127127
/// By default, this method delegates to using `poll_read` on the first
128128
/// buffer in `vec`. Objects which support vectored IO should override
@@ -160,7 +160,7 @@ mod if_std {
160160
///
161161
/// If the object is not ready for writing, the method returns
162162
/// `Ok(Poll::Pending)` and arranges for the current task (via
163-
/// `cx.waker().wake()`) to receive a notification when the object becomes
163+
/// `cx.waker().wake_by_ref()`) to receive a notification when the object becomes
164164
/// readable or is closed.
165165
///
166166
/// # Implementation
@@ -182,7 +182,7 @@ mod if_std {
182182
///
183183
/// If the object is not ready for writing, the method returns
184184
/// `Ok(Poll::Pending)` and arranges for the current task (via
185-
/// `cx.waker().wake()`) to receive a notification when the object becomes
185+
/// `cx.waker().wake_by_ref()`) to receive a notification when the object becomes
186186
/// readable or is closed.
187187
///
188188
/// By default, this method delegates to using `poll_write` on the first
@@ -213,7 +213,7 @@ mod if_std {
213213
///
214214
/// If flushing cannot immediately complete, this method returns
215215
/// `Ok(Poll::Pending)` and arranges for the current task (via
216-
/// `cx.waker().wake()`) to receive a notification when the object can make
216+
/// `cx.waker().wake_by_ref()`) to receive a notification when the object can make
217217
/// progress towards flushing.
218218
///
219219
/// # Implementation
@@ -230,7 +230,7 @@ mod if_std {
230230
///
231231
/// If closing cannot immediately complete, this function returns
232232
/// `Ok(Poll::Pending)` and arranges for the current task (via
233-
/// `cx.waker().wake()`) to receive a notification when the object can make
233+
/// `cx.waker().wake_by_ref()`) to receive a notification when the object can make
234234
/// progress towards closing.
235235
///
236236
/// # Implementation

futures-sink/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub trait Sink<Item> {
5959
///
6060
/// This method returns `Poll::Ready` once the underlying sink is ready to
6161
/// receive data. If this method returns `Poll::Pending`, the current task
62-
/// is registered to be notified (via `cx.waker().wake()`) when `poll_ready`
62+
/// is registered to be notified (via `cx.waker().wake_by_ref()`) when `poll_ready`
6363
/// should be called again.
6464
///
6565
/// In most cases, if the sink encounters an error, the sink will
@@ -95,7 +95,7 @@ pub trait Sink<Item> {
9595
/// via `start_send` have been flushed.
9696
///
9797
/// Returns `Ok(Poll::Pending)` if there is more work left to do, in which
98-
/// case the current task is scheduled (via `cx.waker().wake()`) to wake up when
98+
/// case the current task is scheduled (via `cx.waker().wake_by_ref()`) to wake up when
9999
/// `poll_flush` should be called again.
100100
///
101101
/// In most cases, if the sink encounters an error, the sink will
@@ -108,7 +108,7 @@ pub trait Sink<Item> {
108108
/// has been successfully closed.
109109
///
110110
/// Returns `Ok(Poll::Pending)` if there is more work left to do, in which
111-
/// case the current task is scheduled (via `cx.waker().wake()`) to wake up when
111+
/// case the current task is scheduled (via `cx.waker().wake_by_ref()`) to wake up when
112112
/// `poll_close` should be called again.
113113
///
114114
/// If this function encounters an error, the sink should be considered to

futures-test/src/future/pending_once.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl<Fut: Future> Future for PendingOnce<Fut> {
3939
self.as_mut().future().poll(cx)
4040
} else {
4141
*self.as_mut().polled_before() = true;
42-
cx.waker().wake();
42+
cx.waker().wake_by_ref();
4343
Poll::Pending
4444
}
4545
}

futures-test/src/task/panic_waker.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@ use futures_core::task::{Waker, RawWaker, RawWakerVTable};
22
use core::cell::UnsafeCell;
33
use core::ptr::null;
44

5-
unsafe fn clone_panic_waker(_data: *const()) -> RawWaker {
5+
unsafe fn clone_panic_waker(_data: *const ()) -> RawWaker {
66
raw_panic_waker()
77
}
88

9-
unsafe fn noop(_data: *const()) {
10-
}
9+
unsafe fn noop(_data: *const ()) {}
1110

12-
unsafe fn wake_panic(_data: *const()) {
11+
unsafe fn wake_panic(_data: *const ()) {
1312
panic!("should not be woken");
1413
}
1514

1615
const PANIC_WAKER_VTABLE: RawWakerVTable = RawWakerVTable::new(
1716
clone_panic_waker,
1817
wake_panic,
18+
wake_panic,
1919
noop,
2020
);
2121

@@ -37,7 +37,7 @@ fn raw_panic_waker() -> RawWaker {
3737
/// waker.wake(); // Will panic
3838
/// ```
3939
pub fn panic_waker() -> Waker {
40-
unsafe { Waker::new_unchecked(raw_panic_waker()) }
40+
unsafe { Waker::from_raw(raw_panic_waker()) }
4141
}
4242

4343
/// Get a global reference to a
@@ -52,7 +52,7 @@ pub fn panic_waker() -> Waker {
5252
/// use futures_test::task::panic_waker_ref;
5353
///
5454
/// let waker = panic_waker_ref();
55-
/// waker.wake(); // Will panic
55+
/// waker.wake_by_ref(); // Will panic
5656
/// ```
5757
pub fn panic_waker_ref() -> &'static Waker {
5858
thread_local! {

0 commit comments

Comments
 (0)