Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a custom spinlock-based reader-writer lock implementation for no_std environments, replacing the parking_lot dependency when the std feature is not enabled.
- Implements
RawSpinRwLockusing atomic operations and compare-exchange primitives - Adds conditional compilation to use the custom rwlock in no_std mode while keeping parking_lot for std builds
- Updates Cargo.toml dependencies to make parking_lot optional and adds lock_api
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/sync.rs | New module implementing spinlock-based reader-writer lock with comprehensive tests |
| src/lib.rs | Conditionally includes sync module for no_std builds |
| src/config.rs | Imports custom RwLock for no_std, parking_lot for std builds |
| Cargo.toml | Makes parking_lot optional, adds lock_api dependency, updates std feature |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| #[inline] | ||
| fn try_lock_shared(&self) -> bool { | ||
| let mut state = self.state.load(Ordering::Relaxed); |
There was a problem hiding this comment.
Using Relaxed ordering for the initial load may miss recent state changes from other threads. Consider using Acquire ordering to ensure visibility of writes from unlock operations.
| let mut state = self.state.load(Ordering::Relaxed); | |
| let mut state = self.state.load(Ordering::Acquire); |
There was a problem hiding this comment.
That's not correct, Ordering::Acquire is used compare_exchange_weak
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #140 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 11 12 +1
Lines 489 661 +172
==========================================
+ Hits 489 661 +172 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
78fc66d to
4a6fe75
Compare
4a6fe75 to
28875d8
Compare
Inspired by #139