In a multithreaded context, I am using AtomicWaker
to schedule wake-ups. When wake
or wake_by_ref
is called, does the inner function call immediately begin invoking the next async function pointing to another task, or, is it called sometime after the function call to wake
/wake_by_ref
?
For more reference:
When wake is called, the last line shows a function call:
#[inline]
#[stable(feature = "futures_api", since = "1.36.0")]
pub fn wake(self) {
// The actual wakeup call is delegated through a virtual function call
// to the implementation which is defined by the executor.
let wake = self.waker.vtable.wake;
let data = self.waker.data;
// Don't call `drop` -- the waker will be consumed by `wake`.
crate::mem::forget(self);
// SAFETY: This is safe because `Waker::from_raw` is the only way
// to initialize `wake` and `data` requiring the user to acknowledge
// that the contract of `RawWaker` is upheld.
unsafe { (wake)(data) };
}
I'm concerned that this function call begins execution of another task before finishing the current task. Because, if it does this, then it's necessary to drop any locks in order to prevent deadlocking