Function futures::task::with_unpark_event
source · [−]pub fn with_unpark_event<F, R>(event: UnparkEvent, f: F) -> R where
F: FnOnce() -> R,
recommended to use FuturesUnordered
instead
Expand description
For the duration of the given callback, add an “unpark event” to be triggered when the task handle is used to unpark the task.
Unpark events are used to pass information about what event caused a task to be unparked. In some cases, tasks are waiting on a large number of possible events, and need precise information about the wakeup to avoid extraneous polling.
Every Task
handle comes with a set of unpark events which will fire when
unpark
is called. When fired, these events insert an identifier into a
concurrent set, which the task can read from to determine what events
occurred.
This function immediately invokes the closure, f
, but arranges things so
that task::park
will produce a Task
handle that includes the given
unpark event.
Panics
This function will panic if a task is not currently being executed. That
is, this method can be dangerous to call outside of an implementation of
poll
.