All Packages Class Hierarchy This Package Previous Next Index
Class syd.mpx.Mpx
java.lang.Object
|
+----syd.mpx.Mpx
- public class Mpx
- extends Object
The multiplexer Mpx is a basic a-symmetric synchronization tool. It
implements a non-deterministic request delivery mechanism. Several entities
(emitters) can submit requests to another entity (collector). Each emitter
is distinguished by a unique key. The requests are delivered one at a time,
and the emitter waits until its request is delivered. The collector waits
untils a new request is submitted, if none is present. The collector is also
informed when there are no more alive emitters.
Intended use:
-
Each emitter is given a different identifier, and sets itself as alive
calling the "connect" method of the Mpx. The collector does not execute
any "select" statement before calling the "accept" Mpx method.
-
The collector loops around a "select" statement serving the requests, until
the "select" finally returns a negative value. On the other side, the
emitter loops around a "submit" statement. Once the emitter wants to
terminate the session, it calls the "quit" method, to cancel itself from
the set of "alive" emitters.
-
When the emitter submita a request to the collector, it blocks until the
request is delivered: therefore it could block forever if the collector
does not execute any more "select" methods.
The Mpx is primarily intended as multiplexer among several warm spare
activities (the emitters): each of them periodically reports about its
activity to one centralized entity (the collector), which coordinates
their activity using such reports.
The responsability for its correct use is primarily of the program: the
Mpx does not enforce the above policy.
-
Mpx(int)
- CONSTRUCTOR: creates a new multiplexer.
-
first_alive()
-
ACCESSOR: returns the identifier if the first, with respect to the
ordering of the identifiers, emitter that is alive.
-
is_alive(int)
- ACCESSOR: tests whether the given emitter is alive or not.
-
mpx_accept(int)
- ACCESSOR: blocks until the given emitter becomes alive.
-
mpx_connect(int)
- MUTATOR: sets the emitter as alive.
-
mpx_quit(int)
- MUTATOR: declares itself as not alive; emitter side.
-
mpx_select()
- ACCESSOR: blocks until a request is submitted, or there are no more
alive emitters.
-
mpx_submit(int)
- MUTATOR: submits a request and wait for the request to be delivered;
Emitter side.
-
next_not_alive()
-
ACCESSOR: returns the identifier if the next, with respect to the
ordering of the identifiers, emitter that is not alive.
Mpx
public Mpx(int n)
- CONSTRUCTOR: creates a new multiplexer. No request pending in this
state, and all emitters are considered not alive.
first_alive
public synchronized int first_alive()
- ACCESSOR: returns the identifier if the first, with respect to the
ordering of the identifiers, emitter that is alive.
- Returns:
- an int indicating the emitter, or
-1
if
there are no alive emitters
next_not_alive
public synchronized int next_not_alive()
- ACCESSOR: returns the identifier if the next, with respect to the
ordering of the identifiers, emitter that is not alive.
The Mpx is remindful of the last answer to this method, that therefore
implements a fair, although predictable, choice among non not alive
emitters.
- Returns:
- an int indicating the emitter, or
-1
if
there are no alive emitters
is_alive
public synchronized boolean is_alive(int key)
- ACCESSOR: tests whether the given emitter is alive or not.
Collector side.
- Parameters:
- key - the identifier of an emitter
- Returns:
- s a
boolean
, true
if the emitter
is alive
mpx_accept
public synchronized void mpx_accept(int key) throws InterruptedException
- ACCESSOR: blocks until the given emitter becomes alive. Collector side
- Parameters:
- key - the identifier of an emitter
mpx_select
public synchronized int mpx_select() throws InterruptedException
- ACCESSOR: blocks until a request is submitted, or there are no more
alive emitters. Collector side.
In the first case the key of the requesting emitter is returned,
in the latter the return value is negative.
- Returns:
- an int indicating the emitter that submitted a request, or
that there are no alive emitters
mpx_connect
public synchronized void mpx_connect(int key) throws EmitterAliveException
- MUTATOR: sets the emitter as alive. Emitter side.
- Parameters:
- key - an int that indicates an emitter
mpx_submit
public synchronized void mpx_submit(int key) throws InterruptedException
- MUTATOR: submits a request and wait for the request to be delivered;
Emitter side.
- Parameters:
- key - an int that indicates an emitter
mpx_quit
public synchronized void mpx_quit(int key) throws InterruptedException
- MUTATOR: declares itself as not alive; emitter side.
- Parameters:
- key - an int that indicates an emitter
All Packages Class Hierarchy This Package Previous Next Index