5
5
use marker:: Unpin ;
6
6
use ops;
7
7
use pin:: Pin ;
8
- use task:: { Poll , LocalWaker } ;
8
+ use task:: { Poll , Waker } ;
9
9
10
10
/// A future represents an asynchronous computation.
11
11
///
@@ -25,7 +25,7 @@ use task::{Poll, LocalWaker};
25
25
/// `await!` the value.
26
26
#[ must_use = "futures do nothing unless polled" ]
27
27
pub trait Future {
28
- /// The result of the `Future` .
28
+ /// The type of value produced on completion .
29
29
type Output ;
30
30
31
31
/// Attempt to resolve the future to a final value, registering
@@ -42,16 +42,16 @@ pub trait Future {
42
42
/// Once a future has finished, clients should not `poll` it again.
43
43
///
44
44
/// When a future is not ready yet, `poll` returns `Poll::Pending` and
45
- /// stores a clone of the [`LocalWaker `] to be woken once the future can
45
+ /// stores a clone of the [`Waker `] to be woken once the future can
46
46
/// make progress. For example, a future waiting for a socket to become
47
- /// readable would call `.clone()` on the [`LocalWaker `] and store it.
47
+ /// readable would call `.clone()` on the [`Waker `] and store it.
48
48
/// When a signal arrives elsewhere indicating that the socket is readable,
49
- /// `[LocalWaker ::wake]` is called and the socket future's task is awoken.
49
+ /// `[Waker ::wake]` is called and the socket future's task is awoken.
50
50
/// Once a task has been woken up, it should attempt to `poll` the future
51
51
/// again, which may or may not produce a final value.
52
52
///
53
53
/// Note that on multiple calls to `poll`, only the most recent
54
- /// [`LocalWaker `] passed to `poll` should be scheduled to receive a
54
+ /// [`Waker `] passed to `poll` should be scheduled to receive a
55
55
/// wakeup.
56
56
///
57
57
/// # Runtime characteristics
@@ -74,16 +74,6 @@ pub trait Future {
74
74
/// thread pool (or something similar) to ensure that `poll` can return
75
75
/// quickly.
76
76
///
77
- /// # [`LocalWaker`], [`Waker`] and thread-safety
78
- ///
79
- /// The `poll` function takes a [`LocalWaker`], an object which knows how to
80
- /// awaken the current task. [`LocalWaker`] is not `Send` nor `Sync`, so in
81
- /// order to make thread-safe futures the [`LocalWaker::into_waker`] method
82
- /// should be used to convert the [`LocalWaker`] into a thread-safe version.
83
- /// [`LocalWaker::wake`] implementations have the ability to be more
84
- /// efficient, however, so when thread safety is not necessary,
85
- /// [`LocalWaker`] should be preferred.
86
- ///
87
77
/// # Panics
88
78
///
89
79
/// Once a future has completed (returned `Ready` from `poll`),
@@ -93,18 +83,16 @@ pub trait Future {
93
83
///
94
84
/// [`Poll::Pending`]: ../task/enum.Poll.html#variant.Pending
95
85
/// [`Poll::Ready(val)`]: ../task/enum.Poll.html#variant.Ready
96
- /// [`LocalWaker`]: ../task/struct.LocalWaker.html
97
- /// [`LocalWaker::into_waker`]: ../task/struct.LocalWaker.html#method.into_waker
98
- /// [`LocalWaker::wake`]: ../task/struct.LocalWaker.html#method.wake
99
86
/// [`Waker`]: ../task/struct.Waker.html
100
- fn poll ( self : Pin < & mut Self > , lw : & LocalWaker ) -> Poll < Self :: Output > ;
87
+ /// [`Waker::wake`]: ../task/struct.Waker.html#method.wake
88
+ fn poll ( self : Pin < & mut Self > , waker : & Waker ) -> Poll < Self :: Output > ;
101
89
}
102
90
103
91
impl < ' a , F : ?Sized + Future + Unpin > Future for & ' a mut F {
104
92
type Output = F :: Output ;
105
93
106
- fn poll ( mut self : Pin < & mut Self > , lw : & LocalWaker ) -> Poll < Self :: Output > {
107
- F :: poll ( Pin :: new ( & mut * * self ) , lw )
94
+ fn poll ( mut self : Pin < & mut Self > , waker : & Waker ) -> Poll < Self :: Output > {
95
+ F :: poll ( Pin :: new ( & mut * * self ) , waker )
108
96
}
109
97
}
110
98
@@ -115,7 +103,7 @@ where
115
103
{
116
104
type Output = <<P as ops:: Deref >:: Target as Future >:: Output ;
117
105
118
- fn poll ( self : Pin < & mut Self > , lw : & LocalWaker ) -> Poll < Self :: Output > {
119
- Pin :: get_mut ( self ) . as_mut ( ) . poll ( lw )
106
+ fn poll ( self : Pin < & mut Self > , waker : & Waker ) -> Poll < Self :: Output > {
107
+ Pin :: get_mut ( self ) . as_mut ( ) . poll ( waker )
120
108
}
121
109
}
0 commit comments