Skip to content

Go utility package to provide a simple way to shutdown Goroutines

License

Notifications You must be signed in to change notification settings

jesselucas/shutdown

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Shutdown

Shutdown provides way to create goroutines that can be all shutdown at once and waits for them to all return before continuing

Install

go get -u github.com/jesselucas/shutdown

Usage

https://godoc.org/github.com/jesselucas/shutdown

s := NewShutdown()

for i := 0; i < 10; i++ {
  s.Go(func() { fmt.Println("Some code.") })
}

s.Shutdown()
fmt.Println("All routines shutdown")


// Or use GoFor to pass a function that will loop forever
testLoop := func() {
  fmt.Println("loop forever")
}

s := NewShutdown()

for i := 0; i < 10; i++ {
  s.GoFor(testLoop)
}

// Let's wait to see loop working
time.Sleep(2 * time.Second)

s.Shutdown()
fmt.Println("All routines shutdown")

About

Go utility package to provide a simple way to shutdown Goroutines

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages