Skip to content

GoAethereal/cancel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Cancel

A simplified approach to context.Context for just transmitting cancellation signals.

Installation

go get github.com/GoAethereal/cancel

Examples

{
	sig := cancel.New()
	sig.Cancel()
	<-sig.Done()
	fmt.Println("Termination manual")
}

{
	sig := cancel.New().Timeout(3 * time.Second)
	<-sig.Done()
	fmt.Println("Termination timeout")
}

{
	sig := cancel.New().Deadline(time.Now().Add(4 * time.Second))
	<-sig.Done()
	fmt.Println("Termination deadline")
}

{
	parent := cancel.New()
	child := cancel.New().Propagate(parent)

	parent.Cancel()
	<-child.Done()

	fmt.Println("Termination parent")
}

{
	sig := cancel.New().Timeout(2 * time.Second).Deadline(time.Now().Add(2 * time.Second))
	<-sig.Done()
	fmt.Println("Termination mixed")
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages