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

Mutex requires data to by Sync #74

Open
peopleskai opened this issue Jun 13, 2024 · 0 comments
Open

Mutex requires data to by Sync #74

peopleskai opened this issue Jun 13, 2024 · 0 comments

Comments

@peopleskai
Copy link

peopleskai commented Jun 13, 2024

Hi,

In line https://github.com/lobaro/FreeRTOS-rust/blob/master/freertos-rust/src/mutex.rs#L11 we can see the Mutex API requires the data it holds to have Sync trait for it to implement Sync.

I wanted to understand the reason for this. I believe in the standard library Mutex will be Send+Sync if the data type is Send. https://doc.rust-lang.org/std/sync/struct.Mutex.html#impl-Sync-for-Mutex%3CT%3E

This makes sense since Mutex is what provides the Sync feature for the data. If the data is already Sync, why would it need to be wrapped in a Mutex?

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

1 participant