An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

        

# xsync
simple and powerful sync package

example
```
package main

import (
"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")
}
}
```