File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -382,3 +382,35 @@ func TestTaskGroupMetricsWithCancelledContext(t *testing.T) {
382382 assert .Equal (t , uint64 (5 ), pool .SuccessfulTasks ())
383383 assert .Equal (t , uint64 (5 ), pool .FailedTasks ())
384384}
385+
386+ func TestTaskGroupWaitingTasks (t * testing.T ) {
387+ // Create a pool with limited concurrency
388+ pool := NewPool (10 )
389+
390+ // Create a task group
391+ group := pool .NewGroup ()
392+
393+ start := make (chan struct {})
394+ end := make (chan struct {})
395+
396+ // Submit 20 tasks
397+ for i := 0 ; i < 20 ; i ++ {
398+ group .Submit (func () {
399+ <- start
400+ <- end
401+ })
402+ }
403+
404+ // Start half of the tasks
405+ for i := 0 ; i < 10 ; i ++ {
406+ start <- struct {}{}
407+ }
408+
409+ assert .Equal (t , int64 (10 ), pool .RunningWorkers ())
410+ assert .Equal (t , uint64 (10 ), pool .WaitingTasks ())
411+
412+ // Wait for all tasks to complete
413+ close (start )
414+ close (end )
415+ group .Wait ()
416+ }
You can’t perform that action at this time.
0 commit comments