Skip to content

hinoshiba/goctx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

goctx

  • Make it possible to cancel from goroutine.

owner

func main() {
	own := goctx.NewOwner()
	go gorun(own.NewWorker())
	go gorun(own.NewWorker())
	go gorun(own.NewWorker())
}

routine

func gorun(wk goctx.Worker) {
	for {
		select {
		case <-wk.RecvCancel():
			return
		default:
		}
		//yourroutine
		wk.Cancel() //call the withcancel at owner.
	}
}

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages