Changes in src/Concurrency/Waituntil.cpp [fc0996a:c86b08d]
- File:
-
- 1 edited
-
src/Concurrency/Waituntil.cpp (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Concurrency/Waituntil.cpp
rfc0996a rc86b08d 14 14 // 15 15 16 #include <string> 17 16 18 #include "Waituntil.hpp" 17 18 #include <string>19 20 #include "AST/Copy.hpp"21 19 #include "AST/Expr.hpp" 22 20 #include "AST/Pass.hpp" … … 95 93 case 0: 96 94 try { 97 on_selected( A, clause1 );95 if (on_selected( A, clause1 )) 98 96 doA(); 99 97 } … … 122 120 // the unregister and on_selected calls are needed to support primitives where the acquire has side effects 123 121 // 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 ) 122 if ( ! has_run(clause_statuses[0]) && whenA && unregister_select(A, clause1) && on_selected( A, clause1 ) ) 126 123 doA(); 127 124 ... repeat if above for B and C ... … … 620 617 621 618 // Generates: 622 /* on_selected( target_1, node_1 );... corresponding body of target_1 ...619 /* if ( on_selected( target_1, node_1 )) ... corresponding body of target_1 ... 623 620 */ 624 621 CompoundStmt * GenerateWaitUntilCore::genStmtBlock( const WhenClause * clause, const ClauseData * data ) { … … 626 623 return new CompoundStmt( cLoc, 627 624 { 628 new ExprStmt( cLoc, 629 genSelectTraitCall( clause, data, "on_selected" ) 630 ), 631 ast::deepCopy( clause->stmt ) 625 new IfStmt( cLoc, 626 genSelectTraitCall( clause, data, "on_selected" ), 627 new CompoundStmt( cLoc, 628 { 629 ast::deepCopy( clause->stmt ) 630 } 631 ) 632 ) 632 633 } 633 634 ); … … 641 642 case 0: 642 643 try { 643 on_selected( target1, clause1 );644 dotarget1stmt();644 if (on_selected( target1, clause1 )) 645 dotarget1stmt(); 645 646 } 646 647 finally { clause_statuses[i] = __SELECT_RUN; unregister_select(target1, clause1); } … … 661 662 case 0: 662 663 try { 663 on_selected( target1, clause1 );664 dotarget1stmt();664 if (on_selected( target1, clause1 )) 665 dotarget1stmt(); 665 666 } 666 667 finally { clause_statuses[i] = __SELECT_RUN; unregister_select(target1, clause1); } … … 937 938 } 938 939 940 // 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 941 // std::vector<ptr<CaseClause>> switchCases; 942 943 // int idx = 0; 944 // for ( const auto & clause: stmt->clauses ) { 945 // const CodeLocation & cLoc = clause->location; 946 // switchCases.push_back( 947 // new CaseClause( cLoc, 948 // new CastExpr( cLoc, 949 // new AddressExpr( cLoc, new NameExpr( cLoc, data.at(idx)->targetName ) ), 950 // new BasicType( BasicType::Kind::LongUnsignedInt ), GeneratedFlag::ExplicitCast 951 // ), 952 // { 953 // new CompoundStmt( cLoc, 954 // { 955 // ast::deepCopy( clause->stmt ), 956 // new BranchStmt( cLoc, BranchStmt::Kind::Break, Label( cLoc ) ) 957 // } 958 // ) 959 // } 960 // ) 961 // ); 962 // idx++; 963 // } 964 939 965 return new CompoundStmt( loc, 940 966 { 941 967 new ExprStmt( loc, new UntypedExpr( loc, new NameExpr( loc, "park" ) ) ), 942 968 outerIf 969 // new SwitchStmt( loc, 970 // new NameExpr( loc, statusName ), 971 // std::move( switchCases ) 972 // ) 943 973 } 944 974 ); … … 983 1013 const CodeLocation & cLoc = stmt->clauses.at(idx)->location; 984 1014 985 Expr * baseCond = genSelectTraitCall( stmt->clauses.at(idx), data.at(idx), "register_select" );986 1015 Expr * ifCond; 987 1016 … … 994 1023 ), 995 1024 new CastExpr( cLoc, 996 baseCond,1025 genSelectTraitCall( stmt->clauses.at(idx), data.at(idx), "register_select" ), 997 1026 new BasicType( BasicType::Kind::Bool ), GeneratedFlag::ExplicitCast 998 1027 ), 999 1028 LogicalFlag::AndExpr 1000 1029 ); 1001 } else ifCond = baseCond;1030 } else ifCond = genSelectTraitCall( stmt->clauses.at(idx), data.at(idx), "register_select" ); 1002 1031 1003 1032 return new CompoundStmt( cLoc, … … 1017 1046 ifCond, 1018 1047 genStmtBlock( stmt->clauses.at(idx), data.at(idx) ), 1048 // ast::deepCopy( stmt->clauses.at(idx)->stmt ), 1019 1049 recursiveOrIfGen( stmt, data, idx + 1, elseWhenName ) 1020 1050 )
Note:
See TracChangeset
for help on using the changeset viewer.