-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Add GoRoutineMap.Wait method. #25399
Conversation
It's useful for testing - code under tests creates an operation and my test needs to wait until the operation finishes before evaluating results.
@saad-ali, PTAL |
@@ -73,4 +80,9 @@ func (grm *goRoutineMap) operationComplete(operationName string) { | |||
grm.Lock() | |||
defer grm.Unlock() | |||
delete(grm.operations, operationName) | |||
grm.wg.Done() |
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.
Done()
should be called with defer
. Defer statements are executed in stack order (last in, first executed), so make sure defer grm.wg.Done()
is called after defer grm.Unlock()
.
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.
Fixed
f70d61f
to
6623385
Compare
Fixed review remarks and pushed. Thanks for the review! |
GCE e2e build/test passed for commit 6623385. |
It's useful for testing - code under tests creates an operation and the test needs to wait until the operation finishes before evaluating results.