Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Closer ¶
type Closer struct {
// contains filtered or unexported fields
}
A Closer is an object, which can be used for cancelation of multiple go routines.
Example ¶
var ( wg sync.WaitGroup c = New() n = 0 ) wg.Add(5) go func() { // Wait until other goroutine is counting wg.Wait() c.Close(fmt.Errorf("done")) }() go func() { for { // do some actions here select { case <-c.Chan(): return case <-time.After(1): } if n < 5 { n++ wg.Done() } } }() err := c.Wait() fmt.Printf("received: %s, count: %d\n", err, n)
Output: received: done, count: 5
func (*Closer) Child ¶
Child creates new child closer. When this Closer is closer, it will close the child as well.
Click to show internal directories.
Click to hide internal directories.