Index: doc/uC++toCFA/uC++toCFA.tex
===================================================================
--- doc/uC++toCFA/uC++toCFA.tex	(revision 14c31ebd26aa18f5709bd1a20cc22b7424779f1c)
+++ doc/uC++toCFA/uC++toCFA.tex	(revision bf91d1d3026c4fa5121e502a8752b6b036dc2d63)
@@ -11,6 +11,6 @@
 %% Created On       : Wed Apr  6 14:53:29 2016
 %% Last Modified By : Peter A. Buhr
-%% Last Modified On : Wed Sep 18 21:35:47 2024
-%% Update Count     : 5999
+%% Last Modified On : Tue Oct 22 17:45:48 2024
+%% Update Count     : 6068
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
@@ -183,5 +183,5 @@
 struct S { int i; int j; double m; };  // field i has same type in structures S and T
 struct T { int i; int k; int m; };
-void foo( S s, T t ) @with(s, t)@ {   // open structure scope s and t in parallel
+void foo( S s, T t ) @with( s, t )@ {   // open structure scope s and t in parallel
 	j + k;				$\C[1.6in]{// unambiguous, s.j + t.k}$
 	m = 5.0;			$\C{// unambiguous, s.m = 5.0}$
@@ -357,4 +357,33 @@
 
 
+\section{\texorpdfstring{Structures (object-oriented \protect\vs routine style)}{Structures (object-oriented vs. routine style)}}
+
+\begin{cquote}
+\begin{tabular}{@{}l|l@{}}
+\begin{uC++}
+struct S {
+	int i = 0;  // cheat, implicit default constructor
+	int setter( int j ) { int t = i; i = j; return t; }
+	int getter() { return i; }
+};
+S s;
+@s.@setter( 3 );  // object calls
+int k = @s.@getter();
+\end{uC++}
+&
+\begin{cfa}
+struct S {  int i;  };
+void ?{}( S & s ) { s.i = 0; } // explicit default constructor
+int setter( @S & s,@ int j ) @with( s )@ { int t = i; i = j; return t; }
+int getter( @S & s@ ) @with( s )@ { return i; }
+
+S s;
+setter( @s,@ 3 );  // normal calls
+int k = getter( @s@ );
+\end{cfa}
+\end{tabular}
+\end{cquote}
+
+
 \section{Constructor / Destructor}
 
@@ -362,17 +391,25 @@
 \begin{tabular}{@{}l|l@{}}
 \begin{uC++}
+
 struct S {
-	... // fields
-	@S@( ... ) { ... }
-	@~S@( ... ) { ... }
-};
-\end{uC++}
-&
-\begin{cfa}
+	int i, j;
+	S( int i, int j ) { S::i = i; S::j = j; }
+	~S() {}
+};
+S s = { 1, 2 }, s2{ 1, 2 };
+S * s3 = new S{ 1, 2 };
+S & s4 = *new S{ 1, 2 };
+\end{uC++}
+&
+\begin{cfa}
+#include <stdlib.hfa> // malloc
 struct S {
-	... // fields
-};
-@?{}@( @S & s,@ ... ) { ... }
-@^?{}@( @S & s@ ) { ... }
+	int i, j;
+};
+void ?{}( S & s, int i, int j ) { s.[i, j] = [i, j]; }
+void ^?{}( S & s ) {}
+S s = { 1, 2 }, s2{ 1, 2 };
+S * s3 = &(*malloc()){ 1, 2 };
+S & s4 = (*malloc()){ 1, 2 }; // fails
 \end{cfa}
 \end{tabular}
@@ -422,35 +459,4 @@
 
 
-\section{\texorpdfstring{Structures (object-oriented \protect\vs routine style)}{Structures (object-oriented vs. routine style)}}
-
-\begin{cquote}
-\begin{tabular}{@{}l|l@{}}
-\begin{uC++}
-struct S {
-	int i = 0;  // cheat, implicit default constructor
-	int setter( int j ) { int t = i; i = j; return t; }
-	int getter() { return i; }
-};
-
-S s;
-@s.@setter( 3 );  // object calls
-int k = @s.@getter();
-\end{uC++}
-&
-\begin{cfa}
-struct S {
-	int i;
-};
-void ?{}( S & s ) { s.i = 0; } // explicit default constructor
-int setter( @S & s,@ int j ) @with(s)@ { int t = i; i = j; return t; }
-int getter( @S & s@ ) @with(s)@ { return i; }
-S s;
-setter( @s,@ 3 );  // normal calls
-int k = getter( @s@ );
-\end{cfa}
-\end{tabular}
-\end{cquote}
-
-
 \section{\texorpdfstring{\lstinline{uArray}}{uArray}}
 
@@ -503,4 +509,6 @@
 		... suspend(); ...
 		... _Resume E( ... ) _At partner;
+		... uThisCoroutine(); ...
+
 	}
   public:
@@ -520,4 +528,5 @@
 	... suspend; ... // keyword not routine
 	... resumeAt( partner, ExceptionInst( E, ... ) );
+	... active_coroutine(); ...
 }
 void mem( C & c, ... ) {
@@ -531,4 +540,143 @@
 
 
+\section{\lstinline{COBEGIN}/\lstinline{COFOR}}
+
+\begin{cquote}
+\begin{tabular}{@{}l|ll@{}}
+\begin{uC++}
+
+#include <uCobegin.h>
+int main() {
+	COBEGIN
+		BEGIN osacquire( cout ) << "A" << endl; END
+		BEGIN osacquire( cout ) << "B" << endl; END
+		BEGIN osacquire( cout ) << "C" << endl; END
+		BEGIN osacquire( cout ) << "D" << endl; END
+		BEGIN osacquire( cout ) << "E" << endl; END
+	COEND
+	COFOR( i, 1, 10,
+		osacquire( cout ) << i << endl;
+	)
+}
+\end{uC++}
+&
+\begin{cfa}
+#include <mutex_stmt.hfa>
+#include <$cofor$.hfa>
+int main() {
+	{
+		corun { mutex( sout ) sout | "A"; }
+		corun { mutex( sout ) sout | "B"; }
+		corun { mutex( sout ) sout | "C"; }
+		corun { mutex( sout ) sout | "D"; }
+		corun { mutex( sout ) sout | "E"; }
+	}
+	cofor( i; 10 ) {
+		mutex( sout ) sout | i;
+    }
+}
+\end{cfa}
+\end{tabular}
+\end{cquote}
+
+
+\section{Actor}
+
+\begin{cquote}
+\begin{tabular}{@{}l|ll@{}}
+\begin{uC++}
+#include <iostream>
+using namespace std;
+#include <uActor.h>
+
+struct StrMsg : @public uActor::Message@ {
+	const char * val; // string message
+
+
+	StrMsg( const char * val ) :
+		@Message( uActor::Delete )@, // delete after use
+		val( val ) {}
+};
+_Actor Hello { ${\color{red}\LstCommentStyle{// : public uActor}}$
+	Allocation receive( Message & msg ) {
+		Case( StrMsg, msg ) { // discriminate
+			osacquire( cout ) << msg_d->val << endl;
+		};
+		return Delete;	// delete after use
+	}
+};
+int main() {
+	@uActor::start();@ // start actor system
+	*new Hello() | *new StrMsg( "hello" );
+	*new Hello() | *new StrMsg( "bonjour" );
+	@uActor::stop();@  // wait for all actors to terminate
+}
+\end{uC++}
+&
+\begin{cfa}
+#include <fstream.hfa>
+#include <mutex_stmt.hfa>
+#include <actor.hfa>
+
+struct StrMsg {
+	@inline message;@ // derived message
+	const char * val; // string message
+};
+void ?{}( StrMsg & msg, char * str ) {
+	msg.val = str;
+	@set_allocation( msg, Delete );@ // delete after use
+}
+struct Hello {
+	@inline actor;@ // derived actor
+};
+allocation receive( Hello & receiver, StrMsg & msg ) {
+	mutex( sout ) sout | msg.val;
+	return Delete;	// delete after use
+}
+
+int main() {
+	@start_actor_system();@  // start actor system
+	*(Hello *)new() | *(StrMsg *)new( "hello" );
+	*(Hello *)new() | *(StrMsg *)new( "bonjour" );
+	@stop_actor_system();@  // wait for all actors to terminate
+}
+\end{cfa}
+\end{tabular}
+\end{cquote}
+
+
+\section{Threads}
+
+\begin{cquote}
+\begin{tabular}{@{}l|ll@{}}
+\begin{uC++}
+
+@_Task@ T {
+	// private task fields
+	void main() {
+		... _Resume E( ... ) _At partner;
+		... uThisTask(); ...
+	}
+  public:
+};
+\end{uC++}
+&
+\begin{cfa}
+#include <$thread$.hfa>
+@thread@ T {
+	// private task fields
+
+};
+void main( @T & t@ ) {
+	... resumeAt( partner, ExceptionInst( E, ... ) );
+	... active_thread(); ...
+}
+\end{cfa}
+\\
+\multicolumn{2}{@{}l@{}}{\lstinline{T t; // start thread in main routine}}
+\end{tabular}
+\end{cquote}
+
+
 \section{Locks}
 
@@ -539,9 +687,7 @@
 uOwnerLock m;
 uCondLock s;
-bool avail = true;
 m.acquire();
-if ( ! avail ) s.wait( m );
+if ( ! s.empty() ) s.wait( m );
 else {
-	avail = false;
 	m.release();
 }
@@ -552,10 +698,8 @@
 #include <locks.hfa>
 owner_lock m;
-condition_variable( owner_lock ) s;
-bool avail = true;
+condition_variable( owner_lock ) s;  // generic type on mutex lock
 lock( m );
-if ( ! avail ) wait( s, m );
+if ( ! empty( s ) ) wait( s, m );
 else {
-	avail = false;
 	unlock( m );
 }
@@ -599,35 +743,4 @@
 \\
 \multicolumn{2}{@{}l@{}}{\lstinline{M m;}}
-\end{tabular}
-\end{cquote}
-
-
-\section{Threads}
-
-\begin{cquote}
-\begin{tabular}{@{}l|ll@{}}
-\begin{uC++}
-
-@_Task@ T {
-	// private task fields
-	void main() {
-		... _Resume E( ... ) _At partner;
-	}
-  public:
-};
-\end{uC++}
-&
-\begin{cfa}
-#include <$thread$.hfa>
-@thread@ T {
-	// private task fields
-
-};
-void main( @T & t@ ) {
-	... resumeAt( partner, ExceptionInst( E, ... ) );
-}
-\end{cfa}
-\\
-\multicolumn{2}{@{}l@{}}{\lstinline{T t; // start thread in main routine}}
 \end{tabular}
 \end{cquote}
