-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
81dd6c3
commit 33953f6
Showing
8 changed files
with
287 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package tests | ||
|
||
import ( | ||
"sync" | ||
"time" | ||
) | ||
|
||
// AwaitWaitGroup calls Wait on the given wait | ||
// Returns true if the Wait() call succeeded before the timeout | ||
// Returns false if the Wait() did not return before the timeout | ||
func AwaitWaitGroup(wg *sync.WaitGroup, timeout time.Duration) bool { | ||
doneC := make(chan struct{}) | ||
|
||
go func() { | ||
wg.Wait() | ||
close(doneC) | ||
}() | ||
|
||
select { | ||
case <-doneC: | ||
return true | ||
case <-time.After(timeout): | ||
return false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.