https://github.com/adwpc/xsync
golang simple and powerful sync package, no-panic ttl waitgroup
https://github.com/adwpc/xsync
golang no-panic sync ttl waitgroup
Last synced: 3 months ago
JSON representation
golang simple and powerful sync package, no-panic ttl waitgroup
- Host: GitHub
- URL: https://github.com/adwpc/xsync
- Owner: adwpc
- License: apache-2.0
- Created: 2023-11-17T08:03:20.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-04-18T03:28:54.000Z (about 1 year ago)
- Last Synced: 2025-02-02T13:43:35.324Z (5 months ago)
- Topics: golang, no-panic, sync, ttl, waitgroup
- Language: Go
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# xsync
simple and powerful sync packageexample
```
package mainimport (
"fmt"
"time""github.com/adwpc/xsync"
)func main() {
swg := xsync.NewXWaitGroup()
swg.Add(1)
go func() {
time.Sleep(5 * time.Second) // simulate a long task
swg.Done()
}()
// swg.Done() // extra Done call, will not cause panic
if swg.Wait(3 * time.Second) {
fmt.Println("Timed out")
} else {
fmt.Println("XWaitGroup finished")
}
}
```