Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Concurrency/Waituntil.cpp

    rbccd70a rfc0996a  
    9595                        case 0:
    9696                            try {
    97                                 if (on_selected( A, clause1 ))
     97                                    on_selected( A, clause1 );
    9898                                    doA();
    9999                            }
     
    122122        // the unregister and on_selected calls are needed to support primitives where the acquire has side effects
    123123        // 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) && on_selected( A, clause1 ) )
     124        if ( !has_run(clause_statuses[0]) && whenA && unregister_select(A, clause1) )
     125            on_selected( A, clause1 )
    125126            doA();
    126127        ... repeat if above for B and C ...
     
    619620
    620621// Generates:
    621 /* if ( on_selected( target_1, node_1 )) ... corresponding body of target_1 ...
     622/* on_selected( target_1, node_1 ); ... corresponding body of target_1 ...
    622623*/
    623624CompoundStmt * GenerateWaitUntilCore::genStmtBlock( const WhenClause * clause, const ClauseData * data ) {
     
    625626    return new CompoundStmt( cLoc,
    626627        {
    627             new IfStmt( cLoc,
    628                 genSelectTraitCall( clause, data, "on_selected" ),
    629                 new CompoundStmt( cLoc,
    630                     {
    631                         ast::deepCopy( clause->stmt )
    632                     }
    633                 )
    634             )
     628            new ExprStmt( cLoc,
     629                genSelectTraitCall( clause, data, "on_selected" )
     630            ),
     631            ast::deepCopy( clause->stmt )
    635632        }
    636633    );
     
    644641            case 0:
    645642                try {
    646                     if (on_selected( target1, clause1 ))
    647                         dotarget1stmt();
     643                    on_selected( target1, clause1 );
     644                    dotarget1stmt();
    648645                }
    649646                finally { clause_statuses[i] = __SELECT_RUN; unregister_select(target1, clause1); }
     
    664661        case 0:
    665662            try {
    666                 if (on_selected( target1, clause1 ))
    667                     dotarget1stmt();
     663                on_selected( target1, clause1 );
     664                dotarget1stmt();
    668665            }
    669666            finally { clause_statuses[i] = __SELECT_RUN; unregister_select(target1, clause1); }
     
    940937        }
    941938
    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 
    967939    return new CompoundStmt( loc,
    968940        {
    969941            new ExprStmt( loc, new UntypedExpr( loc, new NameExpr( loc, "park" ) ) ),
    970942            outerIf
    971             // new SwitchStmt( loc,
    972             //     new NameExpr( loc, statusName ),
    973             //     std::move( switchCases )
    974             // )
    975943        }
    976944    );
     
    1015983    const CodeLocation & cLoc = stmt->clauses.at(idx)->location;
    1016984
     985    Expr * baseCond = genSelectTraitCall( stmt->clauses.at(idx), data.at(idx), "register_select" );
    1017986    Expr * ifCond;
    1018987
     
    1025994            ),
    1026995            new CastExpr( cLoc,
    1027                 genSelectTraitCall( stmt->clauses.at(idx), data.at(idx), "register_select" ),
     996                baseCond,
    1028997                new BasicType( BasicType::Kind::Bool ), GeneratedFlag::ExplicitCast
    1029998            ),
    1030999            LogicalFlag::AndExpr
    10311000        );
    1032     } else ifCond = genSelectTraitCall( stmt->clauses.at(idx), data.at(idx), "register_select" );
     1001    } else ifCond = baseCond;
    10331002
    10341003    return new CompoundStmt( cLoc,
     
    10481017                ifCond,
    10491018                genStmtBlock( stmt->clauses.at(idx), data.at(idx) ),
    1050                 // ast::deepCopy( stmt->clauses.at(idx)->stmt ),
    10511019                recursiveOrIfGen( stmt, data, idx + 1, elseWhenName )
    10521020            )
Note: See TracChangeset for help on using the changeset viewer.