- Timestamp:
- Nov 16, 2024, 6:32:00 PM (5 weeks ago)
- Branches:
- master
- Children:
- 95707a3
- Parents:
- 489d3ba
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/uC++toCFA/uC++toCFA.tex
r489d3ba re255902b 11 11 %% Created On : Wed Apr 6 14:53:29 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Wed Nov 13 18:09:58202414 %% Update Count : 62 0713 %% Last Modified On : Fri Nov 15 09:55:34 2024 14 %% Update Count : 6249 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 357 357 358 358 359 \section{Constructor / Destructor} 360 361 \begin{cquote} 362 \begin{tabular}{@{}l|l@{}} 363 \begin{uC++} 364 365 struct S { 366 int i, j; 367 368 @S@( int i, int j ) { S::i = i; S::j = j; } 369 @~S@() {} 370 }; 371 S s1 = { 1, 2 }; 372 373 S * s2 = new S{ 1, 2 }; 374 delete s2; 375 s2 = new S{ 1, 2 }; 376 delete s2; 377 S & s3 = *new S{ 1, 2 }; 378 delete &s3; 379 s3 = *new S{ 1, 2 }; 380 delete &s3; 381 \end{uC++} 382 & 383 \begin{cfa} 384 #include <stdlib.hfa> // new (malloc) 385 struct S { 386 int i, j; 387 }; 388 void @?{}@( S & s, int i, int j ) { s.i = i; s.j = j; } 389 void @^?{}@( S & s ) { s.i = 0; s.j = 0; } 390 391 S s1 = { 1, 2 }; 392 // cannot use 0/1 (zero_t/one_t) with "new" 393 S * s2 = new( 1@n@, 2 ); // n => (int) 394 delete( s2 ); 395 s2 = new( 1n, 2 ); 396 delete( s2 ); 397 S & s3 = *new( 1n, 2 ); 398 delete( s3 ); 399 &s3 = &*new( 1n, 2 ); 400 delete( s3 ); 401 \end{cfa} 402 \end{tabular} 403 \end{cquote} 404 405 359 406 \section{\texorpdfstring{Structures (object-oriented \protect\vs routine style)}{Structures (object-oriented vs. routine style)}} 360 407 … … 381 428 setter( @s,@ 3 ); // normal calls 382 429 int k = getter( @s@ ); 383 \end{cfa}384 \end{tabular}385 \end{cquote}386 387 388 \section{Constructor / Destructor}389 390 \begin{cquote}391 \begin{tabular}{@{}l|l@{}}392 \begin{uC++}393 394 struct S {395 int i, j;396 @S@( int i, int j ) { S::i = i; S::j = j; }397 @~S@() {}398 };399 S s = { 1, 2 }, s2{ 1, 2 };400 S * s3 = new S{ 1, 2 };401 S & s4 = *new S{ 1, 2 };402 \end{uC++}403 &404 \begin{cfa}405 #include <stdlib.hfa> // malloc406 struct S {407 int i, j;408 };409 void @?{}( S & s@, int i, int j ) { s.[i, j] = [i, j]; }410 void @^?{}( S & s@ ) {}411 S s = { 1, 2 }, s2{ 1, 2 };412 S * s3 = &(*malloc()){ 1, 2 };413 S & s4 = (*malloc()){ 1, 2 }; // fails414 430 \end{cfa} 415 431 \end{tabular} … … 734 750 : @public uBarrier@ { // inheritance 735 751 int total; 752 void @last@() { cout << total << endl; } 736 753 public: 737 754 Barrier( unsigned int group ) : … … 740 757 } 741 758 void @block@( int subtotal ) { 759 760 742 761 total += subtotal; 743 762 @uBarrier::block();@ 744 763 } 745 private:746 void @last@() { cout << total << endl; }747 764 }; 748 765 enum { N = 3 }; … … 770 787 @barrier b;@ // containment 771 788 int total; 789 772 790 }; 773 791 void ?{}( Barrier & B, unsigned int group ) with(B) { … … 776 794 } 777 795 unsigned int block( Barrier & B, int subtotal ) with(B) { 778 @mutex( b )@ { total += subtotal; } // use barrier's mutual exclusion779 796 void @last@() { sout | total; } // called by Gth arriving thread 780 @block@( b, last ); // wait for barrier trigger 781 } 782 783 797 @mutex( b )@ { // use barrier's mutual exclusion 798 total += subtotal; 799 return @block@( b, last ); // wait for barrier trigger 800 } 801 } 784 802 enum { N = 3 }; 785 803 Barrier b{ N }; … … 871 889 \enlargethispage{1000pt} 872 890 891 \noindent 873 892 External Scheduling 874 893 \begin{cquote}
Note: See TracChangeset
for help on using the changeset viewer.