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

Use std RwLock instead of parking_lot. #38

Merged
merged 1 commit into from
Feb 17, 2023
Merged

Use std RwLock instead of parking_lot. #38

merged 1 commit into from
Feb 17, 2023

Conversation

BratSinot
Copy link
Contributor

@BratSinot BratSinot commented Feb 17, 2023

Fixes #37.

After sync primitives (Mutex, RwLock, Condvar) from rust std library start use futex in */Linux systems, they become same or faster than parking_lot sync primitives. That the reason switch to std sync primitives.

@zeenix
Copy link
Member

zeenix commented Feb 17, 2023

Nice, many thanks! Kindly add some bried info to the commit log (and squash the additional commits into it while you're at it) on the rationale for the change in the details section?

src/lib.rs Outdated

inner.inactive_receiver_count -= 1;
inner.close_channel();
}
}

fn read_no_poison<T>(lock: &RwLock<T>) -> RwLockReadGuard<'_, T> {
Copy link
Member

Choose a reason for hiding this comment

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

Good work on keeping the existing behavior. But I'm not sure we should. 🤔 Since our locks are strictly internal only, the only code that can panic while holding the lock is our own and can leave us with some inconsistent internal state. Panicking on unlocking is likely the right thing to do here.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for redoing this but I wasn't expecting your to be convinced by my arguments so quickly. 😆

We don't need these methods if we just panic. Just use inner.read().unwrap() and inner.write().unwrap().

Copy link
Member

Choose a reason for hiding this comment

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

Also since we're changing the behavior about poisoning, it would be good to add a sentence about this in the commit log/PR description.

Sorry for being so pedantic. I'm sure this is the last time you've to re-work before we can merge.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

t I wasn't expecting your to be convinced by my arguments so q

Okey, then it make sense to remove read/write_no_poison at all =)

Copy link
Member

Choose a reason for hiding this comment

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

t I wasn't expecting your to be convinced by my arguments so q

Okey, then it make sense to remove read/write_no_poison at all =)

Just to be clear, you mean you will remove these methods as per last suggestion or that you think we should keep the existing behavior of non poisoning? I'll need some arguments for both. :)

The reason I asked you to remove these is because 1. they're just duplicating unwrap 2. their names don't make any sense now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't need these methods

Ow, sorry, right, missed begin of your sentence.

@BratSinot
Copy link
Contributor Author

Kindly add some bried info to the commit log

Done.

Copy link
Member

@zeenix zeenix left a comment

Choose a reason for hiding this comment

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

Almost there.

After sync primitives (Mutex, RwLock, Condvar) from rust std library start use futex in */Linux systems, they become same or faster than parking_lot sync primitives. That the reason switch to std sync primitives.
Panic on poison instead of parking_lot behaviour.
@BratSinot BratSinot requested a review from zeenix February 17, 2023 17:52
@zeenix zeenix merged commit 8f53976 into smol-rs:master Feb 17, 2023
@BratSinot BratSinot deleted the rem_parking_lot branch February 17, 2023 18:03
@zeenix zeenix mentioned this pull request May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Consider switching from parking_lot back to std::sync
2 participants