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

avoid race conditions and add a method to prevent channel leakage #7

Closed
wants to merge 2 commits into from

Conversation

mehdipourfar
Copy link

No description provided.


// Release Closes all the channels associated with goccm
func (c *concurrencyManager) Release() {
close(c.managerCh)
Copy link
Owner

Choose a reason for hiding this comment

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

Why not close channels in Close() method?

Copy link
Author

Choose a reason for hiding this comment

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

First it was there and I also think that it is more natural. But I think you expect to call the close twice from this test:
https://github.com/zenthangplus/goccm/blob/master/goccm_test.go#L22

goccm.go Outdated
@@ -35,7 +40,7 @@ type (
allDoneCh chan bool

// The close flag allows we know when we can close the manager
closed bool
closed atomic.Bool
Copy link
Owner

Choose a reason for hiding this comment

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

atomic.Bool is only available since Go 1.19. Also, other contributor presented another solution using channel. Could you take a look: #9

Copy link
Author

Choose a reason for hiding this comment

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

just fixed it another commit.

@zenthangplus
Copy link
Owner

@mehdipourfar This issue has been fix in this MR #9, please take a look

@mehdipourfar
Copy link
Author

I've looked at it. But it seems too complex for checking a simple flag.

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.

2 participants