diff --git a/tokio/src/runtime/task/join.rs b/tokio/src/runtime/task/join.rs index c2be3fabd7c..b58bccd61a6 100644 --- a/tokio/src/runtime/task/join.rs +++ b/tokio/src/runtime/task/join.rs @@ -133,7 +133,7 @@ impl JoinHandle { /// })); /// /// for handle in &handles { - /// handle.cancel(); + /// handle.abort(); /// } /// /// for handle in handles { @@ -141,7 +141,7 @@ impl JoinHandle { /// } /// } /// ``` - pub fn cancel(&self) { + pub fn abort(&self) { if let Some(raw) = self.raw.raw { raw.shutdown(); } @@ -179,7 +179,7 @@ impl JoinHandle { /// handles.push(handle.into_raw_handle()); /// /// for handle in &handles { - /// handle.cancel(); + /// handle.abort(); /// } /// /// for handle in handles { @@ -223,7 +223,7 @@ impl RawJoinHandle { /// handles.push(handle.into_raw_handle()); /// /// for handle in &handles { - /// handle.cancel(); + /// handle.abort(); /// } /// /// for handle in handles { @@ -231,7 +231,7 @@ impl RawJoinHandle { /// } /// } /// ``` - pub fn cancel(&self) { + pub fn abort(&self) { if let Some(raw) = self.raw { raw.shutdown(); } @@ -247,7 +247,7 @@ impl Future for RawJoinHandle { let mut ret = Poll::Pending; // Keep track of task budget - ready!(crate::coop::poll_proceed(cx)); + let coop = ready!(crate::coop::poll_proceed(cx)); // Raw should always be set. If it is not, this is due to polling after // completion @@ -266,6 +266,10 @@ impl Future for RawJoinHandle { raw.try_read_completion(&mut ret as *mut _ as *mut (), cx.waker()); } + if ret.is_ready() { + coop.made_progress(); + } + ret } }