- Timestamp:
- Nov 11, 2024, 10:35:03 PM (5 weeks ago)
- Branches:
- master
- Children:
- 2295320
- Parents:
- b5f1e850
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/uC++toCFA/uC++toCFA.tex
rb5f1e850 r0cb3479 11 11 %% Created On : Wed Apr 6 14:53:29 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Fri Nov 8 08:22:25202414 %% Update Count : 61 0713 %% Last Modified On : Mon Nov 11 21:51:39 2024 14 %% Update Count : 6144 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 498 498 499 499 500 \section{Coroutine s}500 \section{Coroutine} 501 501 502 502 \begin{cquote} … … 591 591 592 592 struct StrMsg : @public uActor::Message@ { 593 593 594 const char * val; // string message 594 595 595 596 596 StrMsg( const char * val ) : … … 600 600 _Actor Hello { ${\color{red}\LstCommentStyle{// : public uActor}}$ 601 601 Allocation receive( Message & msg ) { 602 Case( StrMsg, msg ) { // discriminate 602 Case( @StartMsg@, msg ) { // discriminate 603 604 } else Case( StrMsg, msg ) { 603 605 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 606 610 } 607 611 }; 608 612 int main() { 609 613 @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 613 619 } 614 620 \end{uC++} … … 623 629 const char * val; // string message 624 630 }; 625 void ?{}( StrMsg & msg, char * str ) { 631 void ?{}( StrMsg & msg, const char * str ) { 632 @set_allocation( msg, Delete );@ // delete after use 626 633 msg.val = str; 627 @set_allocation( msg, Delete );@ // delete after use 628 } 629 struct Hello{630 @inline actor;@ // derived actor631 } ;634 } 635 struct Hello { @inline actor;@ }; // derived actor 636 allocation receive( Hello & receiver, @start_msg_t@ & ) { 637 return Nodelete; 638 } 632 639 allocation receive( Hello & receiver, StrMsg & msg ) { 633 640 mutex( sout ) sout | msg.val; 634 return Delete; // delete after use 641 return Nodelete; // reuse actor 642 } 643 allocation receive( Hello & receiver, @stop_msg_t@ & ) { 644 return Delete; // delete actor 635 645 } 636 646 637 647 int 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} 649 661 650 662 \begin{cquote} … … 710 722 711 723 712 \section{Monitor s}724 \section{Monitor} 713 725 714 726 Internal Scheduling … … 776 788 \end{tabular} 777 789 \end{cquote} 778 \enlargethispage{1000pt} 790 791 \newpage 792 779 793 External Scheduling 780 794 \begin{cquote}
Note: See TracChangeset
for help on using the changeset viewer.