if guard.completed_assigned {
Err(Error::from_hresult(HRESULT(0x80000018u32 as i32))) // E_ILLEGAL_DELEGATE_ASSIGNMENT
} else {
guard.completed_assigned = true; let status = guard.status(); let handler = handler.ok()?;
if status == AsyncStatus::Started {
guard.completed = Some(handler.clone());
} else {
drop(guard);
sender.invoke_completed(handler, status);
}
Ok(())
}
}
fn spawn<F>(&self, sender: &T, f: F) where
F: FnOnce() -> Result<T::Output> + Send + 'static,
{ let result = f(); letmut guard = self.0.lock().unwrap();
debug_assert!(guard.result.is_none());
guard.result = Some(result); let status = guard.status(); let completed = guard.completed.take();
impl IAsyncAction { /// Creates an `IAsyncAction` that waits for the closure to execute on the Windows thread pool. pubfn spawn<F>(f: F) -> Self where
F: FnOnce() -> Result<()> + Send + 'static,
{ let object = ComObject::new(Action(SyncState::new())); let interface = object.to_interface();
impl<T: RuntimeType> IAsyncOperation<T> { /// Creates an `IAsyncOperation<T>` that waits for the closure to execute on the Windows thread pool. pubfn spawn<F>(f: F) -> Self where
F: FnOnce() -> Result<T> + Send + 'static,
{ let object = ComObject::new(Operation(SyncState::new())); let interface = object.to_interface();
impl<P: RuntimeType> IAsyncActionWithProgress<P> { /// Creates an `IAsyncActionWithProgress<P>` that waits for the closure to execute on the Windows thread pool. pubfn spawn<F>(f: F) -> Self where
F: FnOnce() -> Result<()> + Send + 'static,
{ let object = ComObject::new(ActionWithProgress(SyncState::new())); let interface = object.to_interface();
impl<T: RuntimeType, P: RuntimeType> IAsyncOperationWithProgress<T, P> { /// Creates an `IAsyncOperationWithProgress<T, P>` that waits for the closure to execute on the Windows thread pool. pubfn spawn<F>(f: F) -> Self where
F: FnOnce() -> Result<T> + Send + 'static,
{ let object = ComObject::new(OperationWithProgress(SyncState::new())); let interface = object.to_interface();
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.