Merge pull request #1203 from daboross/patch-2
fix(http,server): Update tests to use non-deprecated futures methods.
This commit is contained in:
		| @@ -133,7 +133,7 @@ fn test_body_stream_concat() { | |||||||
|         tx.send(Ok("world".into())).wait().unwrap(); |         tx.send(Ok("world".into())).wait().unwrap(); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|     let total = body.concat().wait().unwrap(); |     let total = body.concat2().wait().unwrap(); | ||||||
|     assert_eq!(total.as_ref(), b"hello world"); |     assert_eq!(total.as_ref(), b"hello world"); | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -160,11 +160,11 @@ where I: AsyncRead + AsyncWrite, | |||||||
|             // us that it is ready until we drain it. However, we're currently |             // us that it is ready until we drain it. However, we're currently | ||||||
|             // finished reading, so we need to park the task to be able to |             // finished reading, so we need to park the task to be able to | ||||||
|             // wake back up later when more reading should happen. |             // wake back up later when more reading should happen. | ||||||
|             self.state.read_task = Some(::futures::task::park()); |             self.state.read_task = Some(::futures::task::current()); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     fn maybe_unpark(&mut self) { |     fn maybe_notify(&mut self) { | ||||||
|         // its possible that we returned NotReady from poll() without having |         // its possible that we returned NotReady from poll() without having | ||||||
|         // exhausted the underlying Io. We would have done this when we |         // exhausted the underlying Io. We would have done this when we | ||||||
|         // determined we couldn't keep reading until we knew how writing |         // determined we couldn't keep reading until we knew how writing | ||||||
| @@ -188,13 +188,13 @@ where I: AsyncRead + AsyncWrite, | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         if let Some(task) = self.state.read_task.take() { |         if let Some(task) = self.state.read_task.take() { | ||||||
|             task.unpark(); |             task.notify(); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     fn try_keep_alive(&mut self) { |     fn try_keep_alive(&mut self) { | ||||||
|         self.state.try_keep_alive(); |         self.state.try_keep_alive(); | ||||||
|         self.maybe_unpark(); |         self.maybe_notify(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     fn can_write_head(&self) -> bool { |     fn can_write_head(&self) -> bool { | ||||||
| @@ -838,21 +838,22 @@ mod tests { | |||||||
|     #[test] |     #[test] | ||||||
|     fn test_conn_parking() { |     fn test_conn_parking() { | ||||||
|         use std::sync::Arc; |         use std::sync::Arc; | ||||||
|         use futures::executor::Unpark; |         use futures::executor::Notify; | ||||||
|  |         use futures::executor::NotifyHandle; | ||||||
|  |  | ||||||
|         struct Car { |         struct Car { | ||||||
|             permit: bool, |             permit: bool, | ||||||
|         } |         } | ||||||
|         impl Unpark for Car { |         impl Notify for Car { | ||||||
|             fn unpark(&self) { |             fn notify(&self, _id: usize) { | ||||||
|                 assert!(self.permit, "unparked without permit"); |                 assert!(self.permit, "unparked without permit"); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         fn car(permit: bool) -> Arc<Unpark> { |         fn car(permit: bool) -> NotifyHandle { | ||||||
|             Arc::new(Car { |             Arc::new(Car { | ||||||
|                 permit: permit, |                 permit: permit, | ||||||
|             }) |             }).into() | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // test that once writing is done, unparks |         // test that once writing is done, unparks | ||||||
| @@ -866,7 +867,7 @@ mod tests { | |||||||
|             assert!(conn.poll_complete().unwrap().is_ready()); |             assert!(conn.poll_complete().unwrap().is_ready()); | ||||||
|             Ok::<(), ()>(()) |             Ok::<(), ()>(()) | ||||||
|         }); |         }); | ||||||
|         ::futures::executor::spawn(f).poll_future(car(true)).unwrap(); |         ::futures::executor::spawn(f).poll_future_notify(&car(true), 0).unwrap(); | ||||||
|  |  | ||||||
|  |  | ||||||
|         // test that flushing when not waiting on read doesn't unpark |         // test that flushing when not waiting on read doesn't unpark | ||||||
| @@ -877,7 +878,7 @@ mod tests { | |||||||
|             assert!(conn.poll_complete().unwrap().is_ready()); |             assert!(conn.poll_complete().unwrap().is_ready()); | ||||||
|             Ok::<(), ()>(()) |             Ok::<(), ()>(()) | ||||||
|         }); |         }); | ||||||
|         ::futures::executor::spawn(f).poll_future(car(false)).unwrap(); |         ::futures::executor::spawn(f).poll_future_notify(&car(false), 0).unwrap(); | ||||||
|  |  | ||||||
|  |  | ||||||
|         // test that flushing and writing isn't done doesn't unpark |         // test that flushing and writing isn't done doesn't unpark | ||||||
| @@ -890,7 +891,7 @@ mod tests { | |||||||
|             assert!(conn.poll_complete().unwrap().is_ready()); |             assert!(conn.poll_complete().unwrap().is_ready()); | ||||||
|             Ok::<(), ()>(()) |             Ok::<(), ()>(()) | ||||||
|         }); |         }); | ||||||
|         ::futures::executor::spawn(f).poll_future(car(false)).unwrap(); |         ::futures::executor::spawn(f).poll_future_notify(&car(false), 0).unwrap(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     #[test] |     #[test] | ||||||
|   | |||||||
| @@ -479,7 +479,7 @@ impl<S> Drop for NotifyService<S> { | |||||||
|         info.active -= 1; |         info.active -= 1; | ||||||
|         if info.active == 0 { |         if info.active == 0 { | ||||||
|             if let Some(task) = info.blocker.take() { |             if let Some(task) = info.blocker.take() { | ||||||
|                 task.unpark(); |                 task.notify(); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -494,7 +494,7 @@ impl Future for WaitUntilZero { | |||||||
|         if info.active == 0 { |         if info.active == 0 { | ||||||
|             Ok(().into()) |             Ok(().into()) | ||||||
|         } else { |         } else { | ||||||
|             info.blocker = Some(task::park()); |             info.blocker = Some(task::current()); | ||||||
|             Ok(Async::NotReady) |             Ok(Async::NotReady) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user