Skip to content

Synchronization for groups of related goroutines

License

Notifications You must be signed in to change notification settings

chinsun1/go-workgroup

 
 

Repository files navigation

go-workgroup

Build Status Coverage Status GoDoc Go Report Card

Synchronization for groups of related goroutines.

Basic usage

// Create workgroup
var wg workgroup.Group
// Create http server
srv := http.Server{Addr: "127.0.0.1:8080"}
wg.Add(func(stop <-chan struct{}) error {
	go func() {
		<-stop
		// Stop http server
		srv.Close()
	}()
	// Start http server
	return srv.ListenAndServe()
})
if err := wg.Run(); err != nil {
	// Handle err
}

Example usage

Inspired by workgroup package.

About

Synchronization for groups of related goroutines

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%