windows-rs: IAsync{Action,Operation}{WithProgress,} are not Send, so their impl Futures cannot be send across threads.
async fn win32_icon(path: &str) -> Result<WinRTImageStream> {
let exe = StorageFile::get_file_from_path_async(path)
.winrt_with_context(|| format!("Get exe in {}", path))?
.await
.winrt_with_context(|| "async of getting StorageFile")?;
let thumb = exe
.get_thumbnail_async_overload_default_size_default_options(ThumbnailMode::SingleItem)
.winrt_with_context(|| "Get thumbnail of file with default options")?
.await
.winrt_with_context(|| "async of getting thumbail")?;
Ok(WinRTImageStream::from(thumb))
}
The above code generates an impl Future
as the output of the async fn that is not Send
, since the underlying impl Future
s for IAsync{Action,Operation}{WithProgress,} are not Send
either. This greatly limits the use of winrt-rs async code as they will have to single-thread bound. Specifically, we can’t use the normal spawn
functions of tokio
, async_std
etc as the Future is not Send, but instead will have to use something like spawn_local
.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16
Sorry for the delay, I’ve been a little swamped working on other parts of the
windows
crate. I looked into this and it should be safe to mark themSend
andSync
. I’ll get that updated.