From: rog@vitanuova.com
To: 9fans@cse.psu.edu
Subject: Re: [9fans] Channel casting
Date: Wed, 21 May 2003 18:27:19 +0100 [thread overview]
Message-ID: <d770e27d2897bc7e3f0638d36f554c27@vitanuova.com> (raw)
In-Reply-To: <3100726675a9ffcb9f2eefc78956dba1@plan9.bell-labs.com>
> For the case you describe, the client typically
> sends a (request, return-channel) pair and
> then recvs from the return channel, which is
> private to that client.
note that if clients adhere correctly to protocol, then it's not
strictly necessary to allocate a new channel each time.
to modify russ's examples:
an echo server:
srvchan := chan of int;
srvreplychan := chan of int;
for(;;){
n := <-srvchan;
srvreplychan <-= n;
}
echothread(srvchan, replychan: chan of int)
{
for(i:=0;; i++){
srvchan <-= i;
j := <-replychan;
sys->print("sent %d, got %d\n", i, j);
}
}
spawn echothread(srvchan, srvreplychan);
spawn echothread(srvchan, srvreplychan);
spawn echothread(srvchan, srvreplychan);
spawn echothread(srvchan, srvreplychan);
since we're using synchronous (unbuffered) channels, and clients
always write, then read, the server is guaranteed to be writing back
to the same client.
sometimes this makes things simpler; other times, sending a reply
channel makes more sense (particularly when the kind of reply might
depend on the particular request).
cheers,
rog.
next prev parent reply other threads:[~2003-05-21 17:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-19 23:15 northern snowfall
2003-05-19 22:24 ` Russ Cox
2003-05-19 22:14 ` Charles Forsyth
2003-05-19 23:29 ` northern snowfall
2003-05-19 22:38 ` Russ Cox
2003-05-19 23:45 ` northern snowfall
2003-05-21 17:27 ` rog [this message]
2003-05-21 17:26 ` Russ Cox
2003-05-21 18:28 ` northern snowfall
2003-05-21 17:33 ` Russ Cox
2003-05-21 18:50 ` rog
2003-05-22 1:09 ` okamoto
2003-05-22 9:46 ` C H Forsyth
2003-05-23 1:07 ` okamoto
2003-05-23 14:10 ` Russ Cox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d770e27d2897bc7e3f0638d36f554c27@vitanuova.com \
--to=rog@vitanuova.com \
--cc=9fans@cse.psu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).