Skip to content
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

Force Send+Sync on ComPtr #12

Open
kvark opened this issue May 16, 2018 · 2 comments
Open

Force Send+Sync on ComPtr #12

kvark opened this issue May 16, 2018 · 2 comments

Comments

@kvark
Copy link

kvark commented May 16, 2018

We've been recently looking in depth at what Metal/Cocoa objects are Send+Sync in gfx-rs/metal-rs#40. Our D3D12 backend in gfx-rs has a similar issue: a lot of unsafe impl Send/Sync for structures containing ComPtr.

What can be said about COM guarantees of thread safety?

This question also touches the problem that all ComPtr wrapped methods are &mut self, which automatically forbids any sharing (in safe code), even though we have examples (e.g. ID3D12Device) that are documented as thread-safe.

@fkaa
Copy link

fkaa commented May 16, 2018

@retep998
Copy link
Owner

In winapi 0.3 all interfaces take &self for their methods, not &mut self. As discussed in IRC quite a bit, COM thread safety is incredibly thorny due to some interfaces being thread safe and some not, as well as thread safety depending how the thread the object was created on was initialized for COM, and whether the thread you are sending the object to was initialized for COM in the right way as well. Since I can make zero guarantees about whether an arbitrary interface is thread safe, I cannot correctly impl Send or Sync for ComPtr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants