https://github.com/dmdv/waitgrouptimeout
WaitGroupTimeout
https://github.com/dmdv/waitgrouptimeout
Last synced: about 1 year ago
JSON representation
WaitGroupTimeout
- Host: GitHub
- URL: https://github.com/dmdv/waitgrouptimeout
- Owner: Dmdv
- Created: 2024-07-02T08:27:18.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-07-02T08:38:42.000Z (almost 2 years ago)
- Last Synced: 2025-02-12T10:28:18.933Z (over 1 year ago)
- Language: Go
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WaitGroupTimeout
An enhanced version of the built-in sync.WaitGroup of the Go,
which supports timeout processing and non-blocking status check
```go
package main
import (
wgt "github.com/dmdv/waitgrouptimeout"
"time"
)
func main() {
wg := wgt.New(true)
wg.Wrap(func() {
time.Sleep(5 * time.Second)
println("Hello, world 1!")
})
wg.Wrap(func() {
time.Sleep(5 * time.Second)
println("Hello, world 2!")
})
wg.Start()
wg.WaitTimeout(2 * time.Second)
if wg.Finished() {
println("Finished")
} else {
println("Not finished")
}
for wg.Finished() != true {
time.Sleep(1 * time.Second)
println("Waiting...")
}
wg.Wait()
}
```