Changeset 0cb3479 for doc


Ignore:
Timestamp:
Nov 11, 2024, 10:35:03 PM (5 weeks ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
2295320
Parents:
b5f1e850
Message:

update uC++toCFA manual with actor changes

File:
1 edited

Legend:

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

    rb5f1e850 r0cb3479  
    1111%% Created On       : Wed Apr  6 14:53:29 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Fri Nov  8 08:22:25 2024
    14 %% Update Count     : 6107
     13%% Last Modified On : Mon Nov 11 21:51:39 2024
     14%% Update Count     : 6144
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    498498
    499499
    500 \section{Coroutines}
     500\section{Coroutine}
    501501
    502502\begin{cquote}
     
    591591
    592592struct StrMsg : @public uActor::Message@ {
     593
    593594        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( StrMsg, msg ) { // discriminate
     602                Case( @StartMsg@, msg ) { // discriminate
     603
     604                } else Case( StrMsg, msg ) {
    603605                        osacquire( cout ) << msg_d->val << endl;
    604                 };
    605                 return Delete;  // delete after use
     606
     607                } else Case( @StopMsg@, msg )
     608                        return Delete;  // delete actor
     609                return Nodelete;  // reuse actor
    606610        }
    607611};
    608612int main() {
    609613        @uActor::start();@ // start actor system
    610         *new Hello() | *new StrMsg( "hello" );
    611         *new Hello() | *new StrMsg( "bonjour" );
    612         @uActor::stop();@  // wait for all actors to terminate
     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
    613619}
    614620\end{uC++}
     
    623629        const char * val; // string message
    624630};
    625 void ?{}( StrMsg & msg, char * str ) {
     631void ?{}( StrMsg & msg, const char * str ) {
     632        @set_allocation( msg, Delete );@ // delete after use
    626633        msg.val = str;
    627         @set_allocation( msg, Delete );@ // delete after use
    628 }
    629 struct Hello {
    630         @inline actor;@ // derived actor
    631 };
     634}
     635struct Hello { @inline actor;@ }; // derived actor
     636allocation receive( Hello & receiver, @start_msg_t@ & ) {
     637        return Nodelete;
     638}
    632639allocation receive( Hello & receiver, StrMsg & msg ) {
    633640        mutex( sout ) sout | msg.val;
    634         return Delete;  // delete after use
     641        return Nodelete;  // reuse actor
     642}
     643allocation receive( Hello & receiver, @stop_msg_t@ & ) {
     644        return Delete;  // delete actor
    635645}
    636646
    637647int main() {
    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}
     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}
    649661
    650662\begin{cquote}
     
    710722
    711723
    712 \section{Monitors}
     724\section{Monitor}
    713725
    714726Internal Scheduling
     
    776788\end{tabular}
    777789\end{cquote}
    778 \enlargethispage{1000pt}
     790
     791\newpage
     792
    779793External Scheduling
    780794\begin{cquote}
Note: See TracChangeset for help on using the changeset viewer.