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

refactor: remove parking-lot dependency #3034

Merged
merged 4 commits into from
Dec 12, 2024

Conversation

dignifiedquire
Copy link
Contributor

@dignifiedquire dignifiedquire commented Dec 12, 2024

Description

Currently there was an inconsistent usage of std::sync::Mutex and parking_lot::Mutex. This normalizes the usage to always use std::sync::Mutex and remove the external dependency.

Breaking Changes

Notes & open questions

Change checklist

  • Self-review.
  • Documentation updates following the style guide, if relevant.
  • Tests if relevant.
  • All breaking changes documented.

@dignifiedquire dignifiedquire requested a review from a team December 12, 2024 10:15
@dignifiedquire dignifiedquire self-assigned this Dec 12, 2024
@dignifiedquire dignifiedquire added this to the v0.30.0 milestone Dec 12, 2024
Copy link

github-actions bot commented Dec 12, 2024

Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/3034/docs/iroh/

Last updated: 2024-12-12T11:53:17Z

Copy link

github-actions bot commented Dec 12, 2024

Netsim report & logs for this PR have been generated and is available at: LOGS
This report will remain available for 3 days.

Last updated for commit: 6afed7b

Copy link
Contributor

@flub flub left a comment

Choose a reason for hiding this comment

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

I'm all for this but would prefer .expect("poisoned") over .unwrap().

@@ -500,6 +499,7 @@ mod tests {
self.shared
.nodes
.lock()
.unwrap()
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer if we used .expect("poisoned") as that way we can more easily treat .unwrap() as "un-audited". (Having done this whole thing about auditing all our unwraps once before 😉 )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

except this one?

@dignifiedquire
Copy link
Contributor Author

I'm all for this but would prefer .expect("poisoned") over .unwrap().

we have never done this, and that a lot of unwraps like this that don't have that.. we can do it in one go as a follow up if you really want to

@dignifiedquire dignifiedquire force-pushed the refactor-remove-parking-lot branch from 92f6e25 to 11fec02 Compare December 12, 2024 11:02
@dignifiedquire
Copy link
Contributor Author

seems we don't have many unwraps.., okay I will change them

@flub
Copy link
Contributor

flub commented Dec 12, 2024

I'm all for this but would prefer .expect("poisoned") over .unwrap().

we have never done this, and that a lot of unwraps like this that don't have that.. we can do it in one go as a follow up if you really want to

For completeness, we have done this:
#1528
#2046

@dignifiedquire
Copy link
Contributor Author

yep, we just missed adding the lints, which is why they can creep back in

@@ -762,7 +799,7 @@ mod tests {
// add address
node_map.add_test_addr(node_addr);
// make it active
node_map.inner.lock().receive_udp(addr);
node_map.inner.lock().unwrap().receive_udp(addr);
Copy link
Contributor

Choose a reason for hiding this comment

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

still unwrap

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's a test, that's fine

@@ -772,7 +809,7 @@ mod tests {
node_map.add_test_addr(node_addr);
}

let mut node_map_inner = node_map.inner.lock();
let mut node_map_inner = node_map.inner.lock().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

still unwrap

@@ -824,6 +866,7 @@ mod tests {
node_map
.inner
.lock()
.unwrap()
Copy link
Contributor

Choose a reason for hiding this comment

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

still unwrap

@@ -508,7 +508,7 @@ mod tests {
node_id: NodeId,
) -> Option<BoxStream<Result<DiscoveryItem>>> {
let addr_info = match self.resolve_wrong {
false => self.shared.nodes.lock().get(&node_id).cloned(),
false => self.shared.nodes.lock().unwrap().get(&node_id).cloned(),
Copy link
Contributor

Choose a reason for hiding this comment

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

still unwrap

@@ -500,6 +499,7 @@ mod tests {
self.shared
.nodes
.lock()
.unwrap()
Copy link
Contributor

Choose a reason for hiding this comment

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

except this one?

@dignifiedquire dignifiedquire added this pull request to the merge queue Dec 12, 2024
Merged via the queue into main with commit 08671bb Dec 12, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants