Changes in src/Concurrency/Waituntil.cpp [fc0996a:bccd70a]
- File:
-
- 1 edited
-
src/Concurrency/Waituntil.cpp (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Concurrency/Waituntil.cpp
rfc0996a rbccd70a 95 95 case 0: 96 96 try { 97 on_selected( A, clause1 );97 if (on_selected( A, clause1 )) 98 98 doA(); 99 99 } … … 122 122 // the unregister and on_selected calls are needed to support primitives where the acquire has side effects 123 123 // so the corresponding block MUST be run for those primitives to not lose state (example is channels) 124 if ( !has_run(clause_statuses[0]) && whenA && unregister_select(A, clause1) ) 125 on_selected( A, clause1 ) 124 if ( ! has_run(clause_statuses[0]) && whenA && unregister_select(A, clause1) && on_selected( A, clause1 ) ) 126 125 doA(); 127 126 ... repeat if above for B and C ... … … 620 619 621 620 // Generates: 622 /* on_selected( target_1, node_1 );... corresponding body of target_1 ...621 /* if ( on_selected( target_1, node_1 )) ... corresponding body of target_1 ... 623 622 */ 624 623 CompoundStmt * GenerateWaitUntilCore::genStmtBlock( const WhenClause * clause, const ClauseData * data ) { … … 626 625 return new CompoundStmt( cLoc, 627 626 { 628 new ExprStmt( cLoc, 629 genSelectTraitCall( clause, data, "on_selected" ) 630 ), 631 ast::deepCopy( clause->stmt ) 627 new IfStmt( cLoc, 628 genSelectTraitCall( clause, data, "on_selected" ), 629 new CompoundStmt( cLoc, 630 { 631 ast::deepCopy( clause->stmt ) 632 } 633 ) 634 ) 632 635 } 633 636 ); … … 641 644 case 0: 642 645 try { 643 on_selected( target1, clause1 );644 dotarget1stmt();646 if (on_selected( target1, clause1 )) 647 dotarget1stmt(); 645 648 } 646 649 finally { clause_statuses[i] = __SELECT_RUN; unregister_select(target1, clause1); } … … 661 664 case 0: 662 665 try { 663 on_selected( target1, clause1 );664 dotarget1stmt();666 if (on_selected( target1, clause1 )) 667 dotarget1stmt(); 665 668 } 666 669 finally { clause_statuses[i] = __SELECT_RUN; unregister_select(target1, clause1); } … … 937 940 } 938 941 942 // C_TODO: will remove this commented code later. Currently it isn't needed but may switch to a modified version of this later if it has better performance 943 // std::vector<ptr<CaseClause>> switchCases; 944 945 // int idx = 0; 946 // for ( const auto & clause: stmt->clauses ) { 947 // const CodeLocation & cLoc = clause->location; 948 // switchCases.push_back( 949 // new CaseClause( cLoc, 950 // new CastExpr( cLoc, 951 // new AddressExpr( cLoc, new NameExpr( cLoc, data.at(idx)->targetName ) ), 952 // new BasicType( BasicType::Kind::LongUnsignedInt ), GeneratedFlag::ExplicitCast 953 // ), 954 // { 955 // new CompoundStmt( cLoc, 956 // { 957 // ast::deepCopy( clause->stmt ), 958 // new BranchStmt( cLoc, BranchStmt::Kind::Break, Label( cLoc ) ) 959 // } 960 // ) 961 // } 962 // ) 963 // ); 964 // idx++; 965 // } 966 939 967 return new CompoundStmt( loc, 940 968 { 941 969 new ExprStmt( loc, new UntypedExpr( loc, new NameExpr( loc, "park" ) ) ), 942 970 outerIf 971 // new SwitchStmt( loc, 972 // new NameExpr( loc, statusName ), 973 // std::move( switchCases ) 974 // ) 943 975 } 944 976 ); … … 983 1015 const CodeLocation & cLoc = stmt->clauses.at(idx)->location; 984 1016 985 Expr * baseCond = genSelectTraitCall( stmt->clauses.at(idx), data.at(idx), "register_select" );986 1017 Expr * ifCond; 987 1018 … … 994 1025 ), 995 1026 new CastExpr( cLoc, 996 baseCond,1027 genSelectTraitCall( stmt->clauses.at(idx), data.at(idx), "register_select" ), 997 1028 new BasicType( BasicType::Kind::Bool ), GeneratedFlag::ExplicitCast 998 1029 ), 999 1030 LogicalFlag::AndExpr 1000 1031 ); 1001 } else ifCond = baseCond;1032 } else ifCond = genSelectTraitCall( stmt->clauses.at(idx), data.at(idx), "register_select" ); 1002 1033 1003 1034 return new CompoundStmt( cLoc, … … 1017 1048 ifCond, 1018 1049 genStmtBlock( stmt->clauses.at(idx), data.at(idx) ), 1050 // ast::deepCopy( stmt->clauses.at(idx)->stmt ), 1019 1051 recursiveOrIfGen( stmt, data, idx + 1, elseWhenName ) 1020 1052 )
Note:
See TracChangeset
for help on using the changeset viewer.