From 766e263f90b908d932cdb2303e943184c3639f98 Mon Sep 17 00:00:00 2001 From: Kenny Kerr Date: Tue, 20 Aug 2024 19:40:27 -0500 Subject: [PATCH] cleanup --- crates/libs/metadata/src/type_name.rs | 1 - .../libs/windows/src/extensions/Foundation/Async.rs | 13 ++++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/crates/libs/metadata/src/type_name.rs b/crates/libs/metadata/src/type_name.rs index e90e083495..19160a7ad6 100644 --- a/crates/libs/metadata/src/type_name.rs +++ b/crates/libs/metadata/src/type_name.rs @@ -15,7 +15,6 @@ impl TypeName { pub const HResult: Self = Self("Windows.Foundation", "HResult"); pub const IAsyncAction: Self = Self("Windows.Foundation", "IAsyncAction"); - pub const IAsyncInfo: Self = Self("Windows.Foundation", "IAsyncInfo"); pub const IAsyncActionWithProgress: Self = Self("Windows.Foundation", "IAsyncActionWithProgress"); pub const IAsyncOperation: Self = Self("Windows.Foundation", "IAsyncOperation"); diff --git a/crates/libs/windows/src/extensions/Foundation/Async.rs b/crates/libs/windows/src/extensions/Foundation/Async.rs index b4f53e3837..60c620af3d 100644 --- a/crates/libs/windows/src/extensions/Foundation/Async.rs +++ b/crates/libs/windows/src/extensions/Foundation/Async.rs @@ -26,8 +26,9 @@ pub trait Async: Interface { fn get_results(&self) -> Result; } -// The `AsyncFuture` is needed to store some extra state needed to keep async execution up to date with possible changes to Rust execution context. -// Each async type implements `IntoFuture` rather than implementing `Future` directly so that this adapter may be used. +// The `AsyncFuture` is needed to store some extra state needed to keep async execution up to date with possible changes +// to Rust execution context. Each async type implements `IntoFuture` rather than implementing `Future` directly so that +// this adapter may be used. pub struct AsyncFuture { // Represents the async execution and provides the virtual methods for setting up a `Completed` handler and // calling `GetResults` when execution is completed. @@ -38,7 +39,7 @@ pub struct AsyncFuture { // A shared waker is needed to keep the `Completed` handler updated. // - `Option` is used to avoid allocations for async objects that have already completed. - // - `Arc` is used to share the `Waker` with the `Completed` handler and and potentially replace the `Waker` + // - `Arc` is used to share the `Waker` with the `Completed` handler and potentially replace the `Waker` // since we don't have the ability to replace the `Completed` handler itself. // - `Mutex` is used to synchronize replacing the `Waker` across threads. waker: Option>>, @@ -63,8 +64,6 @@ impl Future for AsyncFuture { type Output = Result; fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - println!("poll {cx:?}"); - // A status of `Started` just means async execution is still in flight. Since WinRT async is always // "hot start", if its not `Started` then its ready for us to call `GetResults` so we can skip all of // the remaining set up. @@ -74,8 +73,8 @@ impl Future for AsyncFuture { if let Some(shared_waker) = &self.waker { // We have a shared waker which means we're either getting polled again or been transfered to - // another another execution context. Either way, we need to update the shared waker to make sure - // we've got the "current" waker. + // another execution context. As we can't tell the difference, we need to update the shared waker + // to make sure we've got the "current" waker. let mut guard = shared_waker.lock().unwrap(); guard.clone_from(cx.waker());