Skip to content
/ xsync Public

golang simple and powerful sync package, no-panic ttl waitgroup

License

Notifications You must be signed in to change notification settings

adwpc/xsync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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")
	}
}

About

golang simple and powerful sync package, no-panic ttl waitgroup

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages