MultiTask is simple task manager. you can use it to process multiple tasks and receive result from these tasks.
create two task to count number.
mt := NewMultiTask()
mt.Do(func(ch chan<- interface{}) {
for i := 0; i < 100; i++ {
ch <- 1
}
})
mt.Do(func(ch chan<- interface{}) {
for i := 0; i < 100; i++ {
ch <- 1
}
})
cnt := 0
mt.Fetch(func(result interface{}) {
cnt += 1
})
mt.Wait()
create two task, not to recv.
mt := NewMultiTask()
mt.Do(func(ch chan<- interface{}) {
for i := 0; i < 100; i++ {
// do something
}
})
mt.Do(func(ch chan<- interface{}) {
for i := 0; i < 100; i++ {
// do something
}
})
mt.Wait()