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

Weird error when passing guards to another thread #399

Open
Ved-s opened this issue Aug 29, 2023 · 5 comments
Open

Weird error when passing guards to another thread #399

Ved-s opened this issue Aug 29, 2023 · 5 comments

Comments

@Ved-s
Copy link

Ved-s commented Aug 29, 2023



Guards implement Send for some reason?

@bjorn3
Copy link
Contributor

bjorn3 commented Aug 29, 2023

parking_lot's RwLockWriteGuard implements Send when the protected value implements it.

@Amanieu
Copy link
Owner

Amanieu commented Aug 29, 2023

The error message with std is nicer because it uses an unstable feature to directly implement !Send on mutex guards. parking_lot uses a different method (see GuardNoSend) which effectively has the same effect.

@Ved-s
Copy link
Author

Ved-s commented Aug 30, 2023

what was the reason of doing that instead of !Send ?

@bjorn3
Copy link
Contributor

bjorn3 commented Aug 30, 2023

impl !Send for Type {} is unstable, so parking_lot can't use it. The standard library is privileged in that it can use any unstable feature even on stable rustc.

@Ved-s
Copy link
Author

Ved-s commented Aug 30, 2023

Makes sense, though I've seen parking_lot use impl !Sync (ig it's stable?)

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