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

Port::read should take &mut self #75

Closed
MikailBag opened this issue May 7, 2019 · 3 comments · Fixed by #76
Closed

Port::read should take &mut self #75

MikailBag opened this issue May 7, 2019 · 3 comments · Fixed by #76

Comments

@MikailBag
Copy link
Contributor

Currently, this function takes port object through a shared reference.
To my mind, it is not good, because port internal state does mutate after read() (e.g. read is not idempotent, which is unusual for &-functions).
Since Port is Sync, user can by mistake read from port on multiple threads and get strange behaviour.
Finally, this is inconsistent with other similar APIs, like cpuio::Port::read, and std::io::Read::read.

@phil-opp
Copy link
Member

phil-opp commented May 8, 2019

Good point, I fully agree! Do you have time to open a PR for this?

@MikailBag
Copy link
Contributor Author

MikailBag commented May 8, 2019

Thank's for agreement!
Yes, I think I can implement it.

@phil-opp
Copy link
Member

phil-opp commented May 8, 2019

Great, thank you!

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 a pull request may close this issue.

2 participants