55use marker:: Unpin ;
66use ops;
77use pin:: Pin ;
8- use task:: { Poll , LocalWaker } ;
8+ use task:: { Poll , Waker } ;
99
1010/// A future represents an asynchronous computation.
1111///
@@ -25,7 +25,7 @@ use task::{Poll, LocalWaker};
2525/// `await!` the value.
2626#[ must_use = "futures do nothing unless polled" ]
2727pub trait Future {
28- /// The result of the `Future` .
28+ /// The type of value produced on completion .
2929 type Output ;
3030
3131 /// Attempt to resolve the future to a final value, registering
@@ -42,16 +42,16 @@ pub trait Future {
4242 /// Once a future has finished, clients should not `poll` it again.
4343 ///
4444 /// 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
4646 /// 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.
4848 /// 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.
5050 /// Once a task has been woken up, it should attempt to `poll` the future
5151 /// again, which may or may not produce a final value.
5252 ///
5353 /// 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
5555 /// wakeup.
5656 ///
5757 /// # Runtime characteristics
@@ -74,16 +74,6 @@ pub trait Future {
7474 /// thread pool (or something similar) to ensure that `poll` can return
7575 /// quickly.
7676 ///
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- ///
8777 /// # Panics
8878 ///
8979 /// Once a future has completed (returned `Ready` from `poll`),
@@ -93,18 +83,16 @@ pub trait Future {
9383 ///
9484 /// [`Poll::Pending`]: ../task/enum.Poll.html#variant.Pending
9585 /// [`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
9986 /// [`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 > ;
10189}
10290
10391impl < ' a , F : ?Sized + Future + Unpin > Future for & ' a mut F {
10492 type Output = F :: Output ;
10593
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 )
10896 }
10997}
11098
@@ -115,7 +103,7 @@ where
115103{
116104 type Output = <<P as ops:: Deref >:: Target as Future >:: Output ;
117105
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 )
120108 }
121109}
0 commit comments