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

Fix #835 and #837 #836

Merged
merged 2 commits into from
Feb 26, 2025
Merged

Fix #835 and #837 #836

merged 2 commits into from
Feb 26, 2025

Conversation

apocelipes
Copy link
Contributor

@apocelipes apocelipes commented Feb 26, 2025

What does this do?

Fixes #835.
Fixes #837.

For 837: e.stopCh now has only one receiver, and if executorCtx.Done() does not block, it means that the executor has already received the stop signal and called the stop method, so there is no need to do additional operations, just return from the sub-goroutine.
I also use sync.Once to prevent the stop method from being called multiple times before the next call to the start method. This may not be necessary, but it maximizes concurrency security, and it doesn't do any noticeable harm.

Which issue(s) does this PR fix/relate to?

#835
#837

List any changes that modify/break current functionality

Have you included tests for your changes?

Did you document any new/modified functionality?

  • Updated example_test.go
  • Updated README.md

Notes

The two issues have some relevance, so I put the fixes in the same PR. Please don't sqush the commits.

@apocelipes apocelipes changed the title Fix #835 Fix #835 and #837 Feb 26, 2025
Copy link
Contributor

@JohnRoesler JohnRoesler left a comment

Choose a reason for hiding this comment

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

Thanks for digging into these. Concurrency is hard!

@JohnRoesler JohnRoesler merged commit 63f3701 into go-co-op:v2 Feb 26, 2025
5 checks passed
@apocelipes apocelipes deleted the fix-835 branch February 27, 2025 01:20
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.

[BUG] - Goroutine leaks when shutdown [BUG] - Executor deadlocks when it calls stop().
2 participants