futures_intrusive/utils/
mod.rs

1//! Utilities which are used within the library
2
3use core::task::{Context, Waker};
4
5/// Updates a `Waker` which is stored inside a `Option` to the newest value
6/// which is delivered via a `Context`.
7pub fn update_waker_ref(waker_option: &mut Option<Waker>, cx: &Context) {
8    if waker_option
9        .as_ref()
10        .map_or(true, |stored_waker| !stored_waker.will_wake(cx.waker()))
11    {
12        *waker_option = Some(cx.waker().clone());
13    }
14}