Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/uC++toCFA/uC++toCFA.tex

    r0cb3479 r135a2d8  
    1111%% Created On       : Wed Apr  6 14:53:29 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Mon Nov 11 21:51:39 2024
    14 %% Update Count     : 6144
     13%% Last Modified On : Fri Nov  8 08:22:25 2024
     14%% Update Count     : 6107
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    498498
    499499
    500 \section{Coroutine}
     500\section{Coroutines}
    501501
    502502\begin{cquote}
     
    591591
    592592struct StrMsg : @public uActor::Message@ {
    593 
    594593        const char * val; // string message
     594
    595595
    596596        StrMsg( const char * val ) :
     
    600600_Actor Hello { ${\color{red}\LstCommentStyle{// : public uActor}}$
    601601        Allocation receive( Message & msg ) {
    602                 Case( @StartMsg@, msg ) { // discriminate
    603 
    604                 } else Case( StrMsg, msg ) {
     602                Case( StrMsg, msg ) { // discriminate
    605603                        osacquire( cout ) << msg_d->val << endl;
    606 
    607                 } else Case( @StopMsg@, msg )
    608                         return Delete;  // delete actor
    609                 return Nodelete;  // reuse actor
     604                };
     605                return Delete;  // delete after use
    610606        }
    611607};
    612608int main() {
    613609        @uActor::start();@ // start actor system
    614         *new Hello() | uActor::startMsg
    615                 | *new StrMsg( "hello" ) | uActor::stopMsg;
    616         *new Hello() | uActor::startMsg
    617                 | *new StrMsg( "bonjour" ) | uActor::stopMsg;
    618         @uActor::stop();@  // wait for actors to terminate
     610        *new Hello() | *new StrMsg( "hello" );
     611        *new Hello() | *new StrMsg( "bonjour" );
     612        @uActor::stop();@  // wait for all actors to terminate
    619613}
    620614\end{uC++}
     
    629623        const char * val; // string message
    630624};
    631 void ?{}( StrMsg & msg, const char * str ) {
     625void ?{}( StrMsg & msg, char * str ) {
     626        msg.val = str;
    632627        @set_allocation( msg, Delete );@ // delete after use
    633         msg.val = str;
    634 }
    635 struct Hello { @inline actor;@ }; // derived actor
    636 allocation receive( Hello & receiver, @start_msg_t@ & ) {
    637         return Nodelete;
    638 }
     628}
     629struct Hello {
     630        @inline actor;@ // derived actor
     631};
    639632allocation receive( Hello & receiver, StrMsg & msg ) {
    640633        mutex( sout ) sout | msg.val;
    641         return Nodelete;  // reuse actor
    642 }
    643 allocation receive( Hello & receiver, @stop_msg_t@ & ) {
    644         return Delete;  // delete actor
     634        return Delete;  // delete after use
    645635}
    646636
    647637int main() {
    648         @actor_start();@  // start actor system
    649         *(Hello *)new() | start_msg
    650                 | *(StrMsg *)new( "hello" ) | stop_msg;
    651         *(Hello *)new() | start_msg
    652                 | *(StrMsg *)new( "bonjour" ) | stop_msg;
    653         @actor_stop();@  // wait for actors to terminate
    654 }
    655 \end{cfa}
    656 \end{tabular}
    657 \end{cquote}
    658 
    659 
    660 \section{Thread}
     638        @start_actor_system();@  // start actor system
     639        *(Hello *)new() | *(StrMsg *)new( "hello" );
     640        *(Hello *)new() | *(StrMsg *)new( "bonjour" );
     641        @stop_actor_system();@  // wait for all actors to terminate
     642}
     643\end{cfa}
     644\end{tabular}
     645\end{cquote}
     646
     647
     648\section{Threads}
    661649
    662650\begin{cquote}
     
    722710
    723711
    724 \section{Monitor}
     712\section{Monitors}
    725713
    726714Internal Scheduling
     
    788776\end{tabular}
    789777\end{cquote}
    790 
    791 \newpage
    792 
     778\enlargethispage{1000pt}
    793779External Scheduling
    794780\begin{cquote}
Note: See TracChangeset for help on using the changeset viewer.