-
Notifications
You must be signed in to change notification settings - Fork 14
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
Conversation
|
||
// Release Closes all the channels associated with goccm | ||
func (c *concurrencyManager) Release() { | ||
close(c.managerCh) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
@mehdipourfar This issue has been fix in this MR #9, please take a look |
I've looked at it. But it seems too complex for checking a simple flag. |
No description provided.