Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline WakerRef functions #2626

Merged
merged 1 commit into from Jul 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions futures-task/src/waker_ref.rs
Expand Up @@ -18,6 +18,7 @@ pub struct WakerRef<'a> {

impl<'a> WakerRef<'a> {
/// Create a new [`WakerRef`] from a [`Waker`] reference.
#[inline]
pub fn new(waker: &'a Waker) -> Self {
// copy the underlying (raw) waker without calling a clone,
// as we won't call Waker::drop either.
Expand All @@ -31,6 +32,7 @@ impl<'a> WakerRef<'a> {
/// an unsafe way (that will be valid only for a lifetime to be determined
/// by the caller), and the [`Waker`] doesn't need to or must not be
/// destroyed.
#[inline]
pub fn new_unowned(waker: ManuallyDrop<Waker>) -> Self {
Self { waker, _marker: PhantomData }
}
Expand All @@ -39,6 +41,7 @@ impl<'a> WakerRef<'a> {
impl Deref for WakerRef<'_> {
type Target = Waker;

#[inline]
fn deref(&self) -> &Waker {
&self.waker
}
Expand Down