Skip to content

grpcsync/event: Simplify synchronization #8308

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

Merged
merged 2 commits into from
May 12, 2025

Conversation

arjan-bal
Copy link
Contributor

This change avoids using sync.Once and reuses the existing atomic boolean to ensure an event is fired only once.

RELEASE NOTES: N/A

@arjan-bal arjan-bal added the Type: Internal Cleanup Refactors, etc label May 9, 2025
@arjan-bal arjan-bal added this to the 1.73 Release milestone May 9, 2025
Copy link

codecov bot commented May 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.31%. Comparing base (515f377) to head (07f1ca0).
Report is 26 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8308      +/-   ##
==========================================
+ Coverage   82.14%   82.31%   +0.17%     
==========================================
  Files         417      419       +2     
  Lines       41344    41990     +646     
==========================================
+ Hits        33961    34565     +604     
- Misses       5957     5978      +21     
- Partials     1426     1447      +21     
Files with missing lines Coverage Δ
internal/grpcsync/event.go 100.00% <100.00%> (ø)

... and 51 files with indirect coverage changes

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

@arjan-bal arjan-bal requested a review from dfawley May 9, 2025 16:16
Copy link
Member

@dfawley dfawley left a comment

Choose a reason for hiding this comment

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

There is a subtle behavior change in that Fire can now return before the channel is closed. E.g.:

go e.Fire()  // Pretend this wins, but blocks for a second before close(e.c) happens
e.Fire() // This loses and returns false
select {
	case <-e.Done(): // This channel is still open
	default: panic("used to be impossible")
}

But, I don't think this is a behavior that is (or should be) relied upon, so it should be fine.

@dfawley dfawley assigned arjan-bal and unassigned dfawley May 9, 2025
Co-authored-by: Doug Fawley <[email protected]>
@arjan-bal arjan-bal merged commit 709023d into grpc:master May 12, 2025
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants