Skip to content

Commit

Permalink
Rebased and renamed cancel method
Browse files Browse the repository at this point in the history
  • Loading branch information
udoprog committed Jul 30, 2020
1 parent ae9db27 commit f9c6d02
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tokio/src/runtime/task/join.rs
Expand Up @@ -133,15 +133,15 @@ impl<T> JoinHandle<T> {
/// }));
///
/// for handle in &handles {
/// handle.cancel();
/// handle.abort();
/// }
///
/// for handle in handles {
/// assert!(handle.await.unwrap_err().is_cancelled());
/// }
/// }
/// ```
pub fn cancel(&self) {
pub fn abort(&self) {
if let Some(raw) = self.raw.raw {
raw.shutdown();
}
Expand Down Expand Up @@ -179,7 +179,7 @@ impl<T> JoinHandle<T> {
/// handles.push(handle.into_raw_handle());
///
/// for handle in &handles {
/// handle.cancel();
/// handle.abort();
/// }
///
/// for handle in handles {
Expand Down Expand Up @@ -223,15 +223,15 @@ impl RawJoinHandle {
/// handles.push(handle.into_raw_handle());
///
/// for handle in &handles {
/// handle.cancel();
/// handle.abort();
/// }
///
/// for handle in handles {
/// assert!(handle.await.unwrap_err().is_cancelled());
/// }
/// }
/// ```
pub fn cancel(&self) {
pub fn abort(&self) {
if let Some(raw) = self.raw {
raw.shutdown();
}
Expand All @@ -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
Expand All @@ -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
}
}
Expand Down

0 comments on commit f9c6d02

Please sign in to comment.