Skip to content

Conversation

@kigawas
Copy link
Member

@kigawas kigawas commented Oct 9, 2025

Inspired by #139

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 RawSpinRwLock using 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);
Copy link

Copilot AI Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
let mut state = self.state.load(Ordering::Relaxed);
let mut state = self.state.load(Ordering::Acquire);

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not correct, Ordering::Acquire is used compare_exchange_weak

Co-authored-by: Copilot <[email protected]>
@codecov
Copy link

codecov bot commented Oct 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (5cf33d8) to head (28875d8).
⚠️ Report is 1 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kigawas kigawas merged commit 06a7171 into master Oct 10, 2025
17 checks passed
@kigawas kigawas deleted the homemade-rwlock branch October 10, 2025 16:07
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 this pull request may close these issues.

2 participants