Skip to content

Commit

Permalink
Review recommendations:
Browse files Browse the repository at this point in the history
* Added missing ';' after unsafe blocks
* Improved documentation in `State::transition_to_join_handle_dropped`
  on the scenarios in which `JOIN_WAKER` gets unset
  • Loading branch information
tglane committed Dec 5, 2024
1 parent ef31f18 commit cea78d0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions tokio/src/runtime/task/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ where
// 2. The task is not completed so the `JoinHandle` was able to unset
// `JOIN_WAKER` bit itself to get mutable access to the waker.
// The runtime will not access the waker when this flag is unset.
unsafe { self.trailer().set_waker(None) }
unsafe { self.trailer().set_waker(None) };
}

// Drop the `JoinHandle` reference, possibly deallocating the task
Expand Down Expand Up @@ -358,7 +358,7 @@ where
{
// SAFETY: We have COMPLETE=1 and JOIN_INTEREST=0, so
// we have exclusive access to the waker.
unsafe { self.trailer().set_waker(None) }
unsafe { self.trailer().set_waker(None) };
}
}
}));
Expand Down
7 changes: 6 additions & 1 deletion tokio/src/runtime/task/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,12 @@ impl State {

if !snapshot.is_join_waker_set() {
// If the `JOIN_WAKER` bit is unset and the `JOIN_HANDLE` has exclusive access to
// the the join waker and should drop it following this transition.
// the join waker and should drop it following this transition.
// This might happen in two situations:
// 1. The task is not completed and we just unset the `JOIN_WAKer` above in this
// function.
// 2. The task is completed. In that case the `JOIN_WAKER` bit was already unset
// by the runtime during completion.
transition.drop_waker = true;
}

Expand Down

0 comments on commit cea78d0

Please sign in to comment.