File tree Expand file tree Collapse file tree 2 files changed +52
-1
lines changed
Expand file tree Collapse file tree 2 files changed +52
-1
lines changed Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ func (e *innerExecutorImpl) sche_successors(node *innerNode) {
8282
8383 for _ , n := range node .successors {
8484 n .mu .Lock ()
85- if ( n .recyclable () && n .state .Load () == kNodeStateIdle ) || n . Typ == nodeCondition {
85+ if n .recyclable () && n .state .Load () == kNodeStateIdle {
8686 // deps all done or condition node or task has been sched.
8787 n .state .Store (kNodeStateWaiting )
8888 candidate = append (candidate , n )
Original file line number Diff line number Diff line change @@ -432,6 +432,57 @@ func TestTaskflowCondition(t *testing.T) {
432432
433433 })
434434
435+ t .Run ("multiple tasks preceding condition" , func (t * testing.T ) {
436+ tf := gotaskflow .NewTaskFlow ("G" )
437+
438+ A , B , C :=
439+ tf .NewTask ("A" , func () {
440+ fmt .Println ("A" )
441+ q .Put ("A" )
442+ }),
443+ tf .NewTask ("B" , func () {
444+ fmt .Println ("B" )
445+ q .Put ("B" )
446+ }),
447+ tf .NewTask ("C" , func () {
448+ fmt .Println ("C" )
449+ q .Put ("C" )
450+ })
451+
452+ fail , success := tf .NewTask ("failed" , func () {
453+ fmt .Println ("Failed" )
454+ q .Put ("failed" )
455+ t .Fail ()
456+ }), tf .NewTask ("success" , func () {
457+ fmt .Println ("success" )
458+ q .Put ("success" )
459+ })
460+
461+ cond := tf .NewCondition ("cond" , func () uint {
462+ q .Put ("cond" )
463+ return 0
464+ })
465+ A .Precede (cond )
466+ B .Precede (cond )
467+ C .Precede (cond )
468+ cond .Precede (success )
469+ cond .Precede (fail )
470+
471+ // success.Precede(suc)
472+ if err := tf .Dump (os .Stdout ); err != nil {
473+ fmt .Errorf ("%v" , err )
474+ }
475+ executor .Run (tf ).Wait ()
476+
477+ executor .Profile (os .Stdout )
478+ chain .grouping ("A" , "B" , "C" )
479+ chain .grouping ("cond" )
480+ chain .grouping ("success" )
481+
482+ checkTopology (t , q , chain )
483+
484+ })
485+
435486 t .Run ("start with condition node" , func (t * testing.T ) {
436487 i := 0
437488 tf := gotaskflow .NewTaskFlow ("G" )
You can’t perform that action at this time.
0 commit comments