public abstract class One2AnyCallChannel
This is the super-class for one-to-any interface-specific CALL channels, safe for use by one client and many servers.
Shortcut to the Constructor and Method Summaries.
For example, using the same Foo interface as before, we derive:
import org.jcsp.lang.*; public class One2AnyFooChannel extends One2AnyCallChannel implements Foo { ... same body as One2OneFooChannel }
import org.jcsp.lang.*; class B implements CSProcess, Foo { private final ChannelAccept in; public B (final One2OneFooChannel in) { // original constructor this.in = in; } public B (final One2AnyFooChannel in) { // additional constructor this.in = in; } ... rest as before }When wrapping the above to hide its raw method interface, don't forget to include the extra constructor(s):
import org.jcsp.lang.*; public class B2 implements CSProcess { // no Foo interface private final B b; public B2 (final One2OneFooChannel in) { // original constructor b = new B (in); } public B2 (final One2AnyFooChannel in) { // additional constructor b = new B (in); } public void run () { b.run (); } }
For example, the network consisting of one client and several servers:
One2AnyFooChannel c = new One2AnyFooChannel (); final B2[] bServers = new B2[n_bClients]; for (int i = 0; i < bServers.length; i++) { bServers[i] = new B2 (c); } new Parallel ( new CSProcess[] { new A (c), new Parallel (bServers) } ).run ();[Reminder: XXX-any channels are not broadcasters of information. In the above, when A makes a CALL on c, it must not care which of the B2 servers picks it up. The servers compete with each other to service the client.]
Modifiers | Name | Description |
---|---|---|
protected int |
selected |
This may be set during the standard calling sequence to record which method was invoked by a client. |
protected CSProcess |
server |
This holds a reference to a server process so that a client may make the call. |
Type | Name and description |
---|---|
int |
accept(CSProcess server) This is invoked by a server when it commits to accepting a CALL from a client. |
protected void |
fork() This is invoked by a client during the standard calling sequence. |
protected void |
join() This is invoked by a client during the standard calling sequence. |
This may be set during the standard calling sequence to record which method was invoked by a client. It is only safe to do this between the join<TT>join</TT> and fork<TT>fork</TT> elements of that sequence. Either all the CALL channel methods should do this or none - in the latter case, its default value remains as zero. Its value is returned to a server as the result the server's invocation of accept<TT>accept</TT>.
This holds a reference to a server process so that a client may make the call. The reference is only valid between the join<TT>join</TT> and fork<TT>fork</TT> elements of the standard calling sequence. As shown in that sequence, it will need casting up to the relevant interface supported by the specific CALL channel derived from this class.
This is invoked by a server when it commits to accepting a CALL from a client. The parameter supplied must be a reference to this server - see the example from One2OneCallChannel. It will not complete until a CALL has been made. If the derived CALL channel has set the selected field in the way defined by the standard calling sequence, the value returned by this method will indicate which method was called.
server
- the server process receiving the CALL.This is invoked by a client during the standard calling sequence. A server must have invoked an accept<TT>accept</TT> for the client to have got this far in the sequence - see the join<TT>join</TT>. This call unblocks that accept, releasing the server and client to resume separate lives.
This is invoked by a client during the standard calling sequence. It will not complete until a server invokes an accept<TT>accept</TT> on this channel. In turn, that accept will not complete until the client invokes a fork<TT>fork</TT>, after having made its CALL on the server.