Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Concurrency/Waituntil.cpp

    rfc0996a rbccd70a  
    9595                        case 0:
    9696                            try {
    97                                     on_selected( A, clause1 );
     97                                if (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) )
    125             on_selected( A, clause1 )
     124        if ( ! has_run(clause_statuses[0]) && whenA && unregister_select(A, clause1) && on_selected( A, clause1 ) )
    126125            doA();
    127126        ... repeat if above for B and C ...
     
    620619
    621620// 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 ...
    623622*/
    624623CompoundStmt * GenerateWaitUntilCore::genStmtBlock( const WhenClause * clause, const ClauseData * data ) {
     
    626625    return new CompoundStmt( cLoc,
    627626        {
    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            )
    632635        }
    633636    );
     
    641644            case 0:
    642645                try {
    643                     on_selected( target1, clause1 );
    644                     dotarget1stmt();
     646                    if (on_selected( target1, clause1 ))
     647                        dotarget1stmt();
    645648                }
    646649                finally { clause_statuses[i] = __SELECT_RUN; unregister_select(target1, clause1); }
     
    661664        case 0:
    662665            try {
    663                 on_selected( target1, clause1 );
    664                 dotarget1stmt();
     666                if (on_selected( target1, clause1 ))
     667                    dotarget1stmt();
    665668            }
    666669            finally { clause_statuses[i] = __SELECT_RUN; unregister_select(target1, clause1); }
     
    937940        }
    938941
     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
    939967    return new CompoundStmt( loc,
    940968        {
    941969            new ExprStmt( loc, new UntypedExpr( loc, new NameExpr( loc, "park" ) ) ),
    942970            outerIf
     971            // new SwitchStmt( loc,
     972            //     new NameExpr( loc, statusName ),
     973            //     std::move( switchCases )
     974            // )
    943975        }
    944976    );
     
    9831015    const CodeLocation & cLoc = stmt->clauses.at(idx)->location;
    9841016
    985     Expr * baseCond = genSelectTraitCall( stmt->clauses.at(idx), data.at(idx), "register_select" );
    9861017    Expr * ifCond;
    9871018
     
    9941025            ),
    9951026            new CastExpr( cLoc,
    996                 baseCond,
     1027                genSelectTraitCall( stmt->clauses.at(idx), data.at(idx), "register_select" ),
    9971028                new BasicType( BasicType::Kind::Bool ), GeneratedFlag::ExplicitCast
    9981029            ),
    9991030            LogicalFlag::AndExpr
    10001031        );
    1001     } else ifCond = baseCond;
     1032    } else ifCond = genSelectTraitCall( stmt->clauses.at(idx), data.at(idx), "register_select" );
    10021033
    10031034    return new CompoundStmt( cLoc,
     
    10171048                ifCond,
    10181049                genStmtBlock( stmt->clauses.at(idx), data.at(idx) ),
     1050                // ast::deepCopy( stmt->clauses.at(idx)->stmt ),
    10191051                recursiveOrIfGen( stmt, data, idx + 1, elseWhenName )
    10201052            )
Note: See TracChangeset for help on using the changeset viewer.