From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: To: 9fans@cse.psu.edu Subject: Re: [9fans] Channel casting From: "Russ Cox" In-Reply-To: <3EC968C4.9000006@ameritech.net> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Date: Mon, 19 May 2003 18:38:02 -0400 Topicbox-Message-UUID: b3d9e28e-eacb-11e9-9e20-41e7f4b1d025 > Correct? Yes. In Limbo, here's an echo server: srvchan := chan of (int, chan of int); for(;;){ (n, c) := <-srvchan; c <-= n; } And some clients: echothread(srvchan: chan of (int, chan of int)) { c := chan of int; for(i:=0;; i++){ srvchan <-= (i, c); j := <-c; sys->print("sent %d, got %d\n", i, j); } } spawn echothread(srvchan); spawn echothread(srvchan); spawn echothread(srvchan); spawn echothread(srvchan); or something like that. You can do the same with libthread, but everything is uglier in libthread. Russ