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

impl Sync for SerialPort trait #233

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

unlimitedsola
Copy link

@unlimitedsola unlimitedsola commented Dec 12, 2024

Closes #232

There are many alternatives that don't involve unsafe impl, but I believe this is the simplest one that doesn't involve an MSRV bump, nor should it introduce breakage, at least I hope...

One alternative is to use OwnedHandle provided by stdlib. However, doing so requires an MSRV bump to at least 1.63.0, which I've heard would require a major version bump in this library so I refrained from this approach.

Copy link
Contributor

@sirhcel sirhcel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for this PR! Please see my comment below. I'm wondering what's you use case for sharing &SerialPort between threads? At a firs glance there are only a few meaningful things to do with an immutable reference.

src/windows/com.rs Outdated Show resolved Hide resolved
@unlimitedsola
Copy link
Author

I'm wondering what's you use case for sharing &SerialPort between threads? At a firs glance there are only a few meaningful things to do with an immutable reference.

I was trying to display some port information and settings that should only require an immutable reference in another thread. Without impl Sync, however, it will force me to pass ownership to that thread and then get it back.

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

Successfully merging this pull request may close these issues.

Consider impl Sync for SerialPort trait
2 participants