Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Killer ¶
type Killer struct { // C is a channel to receive the kill signal. It is safe with multiple // receive operations from multiple goroutines. // // Technically, C is just closed when Kill is called. Note that reading // from closed channels never gets blocked. C <-chan struct{} // contains filtered or unexported fields }
Killer sends a "kill" signal to goroutines.
Example ¶
package main import ( "fmt" "sync" "github.com/google/webpackager/internal/chanutil" ) func main() { k := chanutil.NewKiller() var wg sync.WaitGroup wg.Add(3) for i := 0; i < 3; i++ { go func(i int, k *chanutil.Killer) { defer wg.Done() <-k.C // Wait for the kill signal. fmt.Printf("Worker %v is killed\n", i) }(i, k) } k.Kill() wg.Wait() }
Output: Worker 0 is killed Worker 1 is killed Worker 2 is killed
Click to show internal directories.
Click to hide internal directories.