|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--lights.TupleSpace
Embodies the concept of a Linda-like tuple space. The traditional
operations provided by Linda, namely the insertion of a tuple with
out
and pattern matching with the blocking operations
in
and rd
, are supported. In addition, the
following features are provided:
inp
and
rdp
;
outg
, ing
,
rdg
, that allow to write and retrieve multiple tuples at
once;
count
operation returning the number of tuples matching
a given template;
Tuple space access can be optimized for space or speed, by specifying
the desired policy (SPACE
or SPEED
) at creation
time. In the former case, each time a tuple is retrieved it is serialized
and deserialized to ensure the copy semantics. In the latter case, a copy
of the serialized form is stored with the tuple at insertion time. This
way, a copy can be retrieved by performing the deserialization only. This
is the default policy.
Field Summary | |
protected int |
optimizationFor
The default for optimization is speed. |
static int |
SPACE
Used to specify that tuple space access should be optimized for space. |
static int |
SPEED
Used to specify that tuple space access should be optimized for speed. |
protected java.util.Vector |
ts
The actual implementation of the tuple space data structure. |
Fields inherited from interface lights.interfaces.ITupleSpace |
DEFAULT_NAME |
Constructor Summary | |
TupleSpace()
Creates a tuple space with a default name, and optimization for speed. |
|
TupleSpace(java.lang.String name)
Creates a tuple space with the name specified by the user, and optimization for speed. |
|
TupleSpace(java.lang.String name,
int optimizeFor)
Creates a tuple space with the name and optimization specified by the user. |
Method Summary | |
int |
count(ITuple template)
Returns a count of the tuples found in the tuple space that match the template. |
java.lang.String |
getName()
Returns the name of the tuple space. |
ITuple |
in(ITuple template)
Withdraws from the tuple space a tuple matching the template specified; if no tuple is found, the caller is suspended until such a tuple shows up in the tuple space. |
ITuple[] |
ing(ITuple template)
Withdraws from the tuple space all the tuple matching the template specified. |
ITuple |
inp(ITuple template)
Withdraws from the tuple space a tuple matching the template specified; if no tuple is found, null is returned. |
void |
out(ITuple tuple)
Inserts a tuple in the tuple space. |
void |
outg(ITuple[] tuples)
Inserts multiple tuples in the tuple space. |
ITuple |
rd(ITuple template)
Reads from the tuple space a copy of a tuple matching the template specified. |
ITuple[] |
rdg(ITuple template)
Reads from the tuple space a copy of all the tuples matching the template specified. |
ITuple |
rdp(ITuple template)
Reads from the tuple space a copy of a tuple matching the template specified. |
java.lang.String |
toString()
Returns a string representation of the tuple space. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int SPEED
public static final int SPACE
protected java.util.Vector ts
protected int optimizationFor
Constructor Detail |
public TupleSpace()
public TupleSpace(java.lang.String name)
name
- the tuple space name.java.lang.IllegalArgumentException
- if the name is null
.public TupleSpace(java.lang.String name, int optimizeFor)
name
- the tuple space name.optimizeFor
- either of the values SPACE
and
SPEED
.java.lang.IllegalArgumentException
- if the optimization parameter is not
valid, or the name is null
.Method Detail |
public java.lang.String getName()
getName
in interface ITupleSpace
public void out(ITuple tuple) throws TupleSpaceException
out
in interface ITupleSpace
tuple
- The tuple to be inserted.TupleSpaceException
- if an error occurs in the implementation.java.lang.IllegalArgumentException
- if the tuple has no fields.public void outg(ITuple[] tuples) throws TupleSpaceException
outg
in interface ITupleSpace
tuples
- An array containing the tuples to be inserted.TupleSpaceException
- if an error occurs in the
implementation.public ITuple in(ITuple template) throws TupleSpaceException
in
in interface ITupleSpace
template
- the template used for matching.TupleSpaceException
- if an error in the implementation.public ITuple inp(ITuple template) throws TupleSpaceException
null
is returned. If
multiple matching tuples are found, the one returned is selected
non-deterministically.inp
in interface ITupleSpace
template
- the template used for matching.null
if none is
found.TupleSpaceException
- if an error in the implementation.public ITuple[] ing(ITuple template) throws TupleSpaceException
null
is returned.ing
in interface ITupleSpace
template
- the template used for matching.null
if none is
found.TupleSpaceException
- if an error in the implementation.public ITuple rd(ITuple template) throws TupleSpaceException
rd
in interface ITupleSpace
template
- the template used for matching.TupleSpaceException
- if an error in the implementation.public ITuple rdp(ITuple template) throws TupleSpaceException
null
is returned. If
multiple matching tuples are found, the one returned is selected
non-deterministically.rdp
in interface ITupleSpace
template
- the template used for matching.null
if
none is found.TupleSpaceException
- if an error in the implementation.public ITuple[] rdg(ITuple template) throws TupleSpaceException
null
is
returned. Conventionally, a tuple with no fields matches any other tuple.rdg
in interface ITupleSpace
template
- the template used for matching.null
if
none is found.TupleSpaceException
- if an error in the implementation.public int count(ITuple template) throws TupleSpaceException
count
in interface ITupleSpace
template
- the template used for matching.TupleSpaceException
- if an error in the implementation.public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |