You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am running an application that consistently operates with a specific number of workers. Additionally, when a worker discovers work, it requires a boost from the pool. To achieve this, a limited shared pool for boosting is necessary.
Proposed Feature
The idea is to introduce a Join functionality to the Group, enabling the current goroutine not only to wait for all tasks in the group to complete but also to assist in executing the tasks within it. So the general flow is:
When a goroutine calls Join on a Group, it becomes part of the execution pool for that group.
The goroutine waits for all tasks within the group to finish, actively participating in executing these tasks rather than idly waiting.
Example
package main
import (
"fmt""github.com/alitto/pond"
)
funcmain() {
// Create a poolpool:=pond.New(10, 1000)
deferpool.StopAndWait()
// Create a task groupgroup:=pool.Group()
// Submit a group of tasksfori:=0; i<20; i++ {
n:=igroup.Submit(func() {
fmt.Printf("Running group task #%d\n", n)
})
}
// Join pool for this group and help for all tasks in the group to completegroup.Join()
}
Other
Maybe for consistency this functionality also should be added to the WorkerPool object itself, but I cant imagine situation where it can be needed.
The text was updated successfully, but these errors were encountered:
opengs
changed the title
Feature request: Add "Join" functionality to pool group
Feature request: Add "Join" functionality to the group
May 27, 2024
Problem
I am running an application that consistently operates with a specific number of workers. Additionally, when a worker discovers work, it requires a boost from the pool. To achieve this, a limited shared pool for boosting is necessary.
Proposed Feature
The idea is to introduce a Join functionality to the Group, enabling the current goroutine not only to wait for all tasks in the group to complete but also to assist in executing the tasks within it. So the general flow is:
Join
on a Group, it becomes part of the execution pool for that group.Example
Other
Maybe for consistency this functionality also should be added to the
WorkerPool
object itself, but I cant imagine situation where it can be needed.The text was updated successfully, but these errors were encountered: