Individual task result #48
Replies: 1 comment 1 reply
-
Hi! // Create a pool
pool := pond.New(10, 0, pond.MinWorkers(10))
// Create a buffered channel to collect the results
results := make(chan int, 1000)
// Submit 1000 tasks
for i := 0; i < 1000; i++ {
n := i
pool.Submit(func() {
// Send the result of this task to the channel
results <- someComplexFn(n)
})
}
// Stop the pool and wait for all submitted tasks to complete
pool.StopAndWait()
// Print task results
for result := range results {
fmt.Println(result)
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I am trying to figure out a way to get results of all the tasks separately. Does this pond library supports it? Currently i see that there is a error field which gets overridden. I am looking for something like result channel where all the task errors can be propagated back?
Thanks
Pasu
Beta Was this translation helpful? Give feedback.
All reactions