New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add AgileReference #1474
Add AgileReference #1474
Conversation
Thanks @Nerixyz! I'll take a closer look soon when I have a moment. |
I'd like to add an example to the docs but I'm not sure how to do it. Specifically, I'd like to replicate the C#/WinRT example. This is the example: use windows::{core::AgileReference, UI::Popups::PopupMenu};
let non_agile = PopupMenu::new().unwrap();
let agile_reference = AgileReference::new(&non_agile).unwrap();
std::thread::spawn(move || {
let popup = agile_reference.resolve().unwrap();
}); This doesn't compile, because the |
#1429 discusses the same problem. I'm not yet sure how to resolve that, but let's leave the example for now. I have to think a bit more about how to tackle documentation. |
This is my attempt at adding an
AgileReference
to send references across threads, fixes #236.AgileReference
is generic over the type it's wrapping as this ensures the type wrapped remains the same.In
AgileReference::resolve
I wasn't too sure how to return the correct type. I made the pointer,IUnknown
is wrapping, public for the module, so i can construct a new instance (maybe transmuting would be fine as well, as long asptr
isn't null).It returns the result of the
cast
. I can't directly transmute to theT
since the size ofT
isn't known (even though it should always be the size of a pointer).A better test and documentation is still missing.