pub struct DetectDispatcher { /* private fields */ }Expand description
Implements a dispatcher that is either set at construction or detected and cached on first use.
This is intended to be used inside futures to implement detecting the current dispatcher on first poll if the instigator of the future did not specify a dispatcher to run on.
Implementations§
Source§impl DetectDispatcher
impl DetectDispatcher
Sourcepub fn new(with_dispatcher: impl AsAsyncDispatcherRef) -> DetectDispatcher
pub fn new(with_dispatcher: impl AsAsyncDispatcherRef) -> DetectDispatcher
Use this to pre-set the dispatcher so that future calls to GetAsyncDispatcher will
return is dispatcher instead of trying to get the default one.
Sourcepub fn get_or_detect(&self) -> Result<&AsyncDispatcher, Status>
pub fn get_or_detect(&self) -> Result<&AsyncDispatcher, Status>
Gets the dispatcher if set in the constructor, or attempts to retrieve the current
dispatcher as set by crate::CurrentDispatcher::set (or the underlying async-default
api).
Use this in a std::task::Poll implementation to defer finding the current dispatcher until the
future is being run on the dispatcher.
Once a dispatcher has been set or detected, that dispatcher will be held and returned for all future calls.
Returns [Status::BAD_STATE] if there is no dispatcher set or detected.
Sourcepub fn get(&self) -> Option<&AsyncDispatcher>
pub fn get(&self) -> Option<&AsyncDispatcher>
Gets the dispatcher if it had been previously set or detected. If it hasn’t, this will return None.