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

feat: replace mutex with state loop and channels in protocol #505

Merged
merged 1 commit into from Mar 2, 2024

Conversation

rakshasa
Copy link
Contributor

No description provided.

@agaffney
Copy link
Contributor

This looks interesting, but how does it help? The stated purpose of this PR is to get rid of the state mutex, but was it causing a problem?

@rakshasa
Copy link
Contributor Author

The state of the protocol is conceptually separate from of the recv and send loops, and by separating it out it makes the control flow much clearer.

This makes the code easier to read and future changes to state flow easier to implement.

In addition the send loop was locking the state mutex for the full duration of the send loop block, including where it writes to the muxerSendChan.

@agaffney
Copy link
Contributor

I'm not ignoring this. I just need some time to really look this over and understand it. In the meantime, could you rebase it against current main for the test race fixes?

Copy link
Contributor

@agaffney agaffney left a comment

Choose a reason for hiding this comment

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

This looks great. It took me a little while to wrap my head around what was happening in some places, but everything (now) makes sense.

I'm not a super fan of the named anonymous functions embedded in larger functions, partly for function size reasons, partly because it reminds me a bit too much of Python 😅, but it's good as it is.

@agaffney agaffney merged commit 01a7fb4 into blinklabs-io:main Mar 2, 2024
6 checks passed
@agaffney
Copy link
Contributor

agaffney commented Mar 2, 2024

@rakshasa thank you for your contribution!

@rakshasa rakshasa deleted the feat/state-loop branch March 3, 2024 13:11
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.

None yet

2 participants