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

RuntimeContext should not be Send or Sync #60

Closed
rbtying opened this issue Jan 22, 2019 · 2 comments
Closed

RuntimeContext should not be Send or Sync #60

rbtying opened this issue Jan 22, 2019 · 2 comments

Comments

@rbtying
Copy link
Contributor

rbtying commented Jan 22, 2019

RuntimeContext is a wrapper around RoInitialize and RoUninitialize, which initialize (and uninitialize) the WinRT runtime per thread.

Calling RoUninitialize from a different thread than RoInitialize is not allowed.

To fix this, we can replace the inner () with PhantomData<*mut ()>, which is also a zero-size type and (by virtue of containing a pointer) is not automatically Send and Sync. In the future (i.e. when more stuff is stablized), we can explicitly do impl !Send for RuntimeContext.

@Boddlnagg
Copy link
Collaborator

Thanks! Would you like to prepare a PR?
Issue #18 is also about RuntimeContext, maybe you have some ideas there as well?

@rbtying
Copy link
Contributor Author

rbtying commented Jan 22, 2019

Yup, I'll send something over when I get a chance -- ran across this while looking at the landscape for COM things in Rust, and haven't finished setting everything up yet (CoInitialize has the same issue, haha).

c.f. #18, I think that will require more reading / playing with types to get right. Worth doing, but needs more thought.

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

2 participants