|
CSP for Java (JCSP) 1.0-rc4 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jcsp.lang.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.
One2OneCallChannel
for general information about CALL channels.
Documented here is information specific to this 1-any version.
For example, using the same Foo interface as before, we derive:
import jcsp.lang.*; public class One2AnyFooChannel extends One2AnyCallChannel implements Foo { ... same body as One2OneFooChannel }
import 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 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 (); } }
accept
or not to accept a One2AnyFooChannel - it cannot back off because
of some other event.
Parallel
.
For example, the network consisting of one client and several servers:
_____________ | | c | A |----------<->--------------------------------------------- |_____________| One2AnyFooChannel | | | __|___ __|___ __|___ | | | | | | | B2 | | B2 | ... | B2 | |______| |______| |______|where A is unchanged from its definition in One2OneCallChannel, is implemented by:
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.]
One2OneCallChannel
,
Any2OneCallChannel
,
Any2AnyCallChannel
,
Alternative
, Serialized FormField Summary | |
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. |
Constructor Summary | |
One2AnyCallChannel()
|
Method Summary | |
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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected CSProcess server
join
and fork
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.protected int selected
join
and fork
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
.Constructor Detail |
public One2AnyCallChannel()
Method Detail |
public int accept(CSProcess server)
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.accept
in interface ChannelAccept
server
- the server process receiving the CALL.protected void join()
accept
on this channel. In turn, that accept
will not complete until the client invokes a fork
,
after having made its CALL on the server.protected void fork()
accept
for the client to have got this far in the sequence - see
the join
. This call unblocks that accept,
releasing the server and client to resume separate lives.
|
CSP for Java (JCSP) 1.0-rc4 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |