Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Walk ¶
type Walk struct { Burst int // Burst will be set to 1 if less than 1 // contains filtered or unexported fields }
Example ¶
package main import ( "context" "fmt" "github.com/searKing/golang/go/x/pool" ) func main() { // chan WalkInfo walkChan := make(chan interface{}, 0) p := pool.Walk{ Burst: 1, } defer p.Wait() p.Walk(context.Background(), walkChan, func(name interface{}) error { fmt.Printf("%s\n", name) return nil }) for i := 0; i < 5; i++ { walkChan <- fmt.Sprintf("%d", i) } close(walkChan) }
Output: 0 1 2 3 4
func (*Walk) TrySetError ¶
func (*Walk) Walk ¶
func (p *Walk) Walk(ctx context.Context, taskChan <-chan interface{}, procFn WalkFunc) (doneC <-chan struct{})
Walk will consume all tasks parallel and block until ctx.Done() or taskChan is closed. Walk returns a channel that's closed when work done on behalf of this walk should be canceled. Done may return nil if this walk can never be canceled. Successive calls to Done return the same value. The close of the Done channel may happen asynchronously, after the cancel function returns.
Click to show internal directories.
Click to hide internal directories.