// The "Ready" implementations don't need to store the handler since the handler is invoked immediately // but still need to confirm that `SetCompleted` is called at most once. fn invoke_completed(&self, sender: &T, handler: Ref<T::CompletedHandler>) -> Result<()> { if !self.set_completed.swap(true, Ordering::SeqCst) {
sender.invoke_completed(handler.ok()?, self.status());
Ok(())
} else {
Err(Error::from_hresult(HRESULT(0x80000018u32 as i32))) // E_ILLEGAL_DELEGATE_ASSIGNMENT
}
}
// The `From` implementation is not used here since we don't want to transfer any error object to the calling thread. // That happens when `GetResults` is called. fn error_code(&self) -> HRESULT { match &self.result {
Ok(_) => HRESULT(0),
Err(error) => error.code(),
}
}
}
impl IAsyncAction { /// Creates an `IAsyncAction` that is immediately ready with a value. pubfn ready(result: Result<()>) -> Self {
ReadyAction(ReadyState::new(result)).into()
}
}
impl<T: RuntimeType> IAsyncOperation<T> { /// Creates an `IAsyncOperation<T>` that is immediately ready with a value. pubfn ready(result: Result<T>) -> Self {
ReadyOperation(ReadyState::new(result)).into()
}
}
impl<P: RuntimeType> IAsyncActionWithProgress<P> { /// Creates an `IAsyncActionWithProgress<P>` that is immediately ready with a value. pubfn ready(result: Result<()>) -> Self {
ReadyActionWithProgress(ReadyState::new(result)).into()
}
}
impl<T: RuntimeType, P: RuntimeType> IAsyncOperationWithProgress<T, P> { /// Creates an `IAsyncOperationWithProgress<T, P>` that is immediately ready with a value. pubfn ready(result: Result<T>) -> Self {
ReadyOperationWithProgress(ReadyState::new(result)).into()
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.