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

embassy-sync: Add RwLock #1394

Open
PegasisForever opened this issue Apr 25, 2023 · 6 comments · May be fixed by #3932
Open

embassy-sync: Add RwLock #1394

PegasisForever opened this issue Apr 25, 2023 · 6 comments · May be fixed by #3932
Labels
e-sync kind-feature New feature or request

Comments

@PegasisForever
Copy link
Contributor

Something like async-std's RwLock would be extremely helpful for implementing async programs.

@Dirbaio Dirbaio added kind-feature New feature or request e-sync labels Apr 25, 2023
@PegasisForever
Copy link
Contributor Author

PegasisForever commented Apr 25, 2023

I think I can give this a shot, I already got a prototype working. Is there anyway I can write tests for asynchronous primitives running on embassy's executor? Or I just create a normal test which runs the rwlock using tokio?

@Dirbaio
Copy link
Member

Dirbaio commented Apr 25, 2023

There's already some tests using futures-test: https://github.com/embassy-rs/embassy/blob/master/embassy-sync/src/channel.rs#L472

Using another executor is fine, embassy-sync is executor-independent and using embassy-executor would be annoying for tests because tasks are statically allocated.

@PegasisForever
Copy link
Contributor Author

Didn't saw that, thanks!

@elpiel
Copy link
Contributor

elpiel commented Apr 26, 2023

Awesome idea for a feature. I've wondered why there hasn't been anything like that so far.

@Ragarnoy
Copy link
Contributor

How hard to implement would this be for a beginner?

@PegasisForever
Copy link
Contributor Author

@Ragarnoy This is my current implementation so far: https://github.com/McMaster-Rocketry-Team/rust-monorepo/blob/master/vlfs/src/utils/rwlock.rs It works, however it is not fair, meaning too many readers can starve writers.

AlixANNERAUD added a commit to AlixANNERAUD/embassy that referenced this issue Feb 28, 2025
@AlixANNERAUD AlixANNERAUD linked a pull request Feb 28, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e-sync kind-feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants