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:

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.


Constructor Index

 o Mpx(int)
CONSTRUCTOR: creates a new multiplexer.

Method Index

 o first_alive()
ACCESSOR: returns the identifier if the first, with respect to the ordering of the identifiers, emitter that is alive.
 o is_alive(int)
ACCESSOR: tests whether the given emitter is alive or not.
 o mpx_accept(int)
ACCESSOR: blocks until the given emitter becomes alive.
 o mpx_connect(int)
MUTATOR: sets the emitter as alive.
 o mpx_quit(int)
MUTATOR: declares itself as not alive; emitter side.
 o mpx_select()
ACCESSOR: blocks until a request is submitted, or there are no more alive emitters.
 o mpx_submit(int)
MUTATOR: submits a request and wait for the request to be delivered; Emitter side.
 o next_not_alive()
ACCESSOR: returns the identifier if the next, with respect to the ordering of the identifiers, emitter that is not alive.

Constructors

 o Mpx
 public Mpx(int n)
CONSTRUCTOR: creates a new multiplexer. No request pending in this state, and all emitters are considered not alive.

Methods

 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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