All Packages Class Hierarchy This Package Previous Next Index
Class com.ibm.tspaces.Waiter
java.lang.Object
|
+----com.ibm.tspaces.Waiter
- public class Waiter
- extends Object
- implements Callback
The Waiter class is used as the simplest type of callback method for making the
basic synchronous tuple space operations actually synchronous in the case where
the server is going to do a call back.
Actually, it is even used when there is no callback just to make things uniform.
From someone talking to the server through the tuple space interface, there should
be no way to tell if a callback was issued or the command immediately returned ---
at least from a programming perspective there is no reason to have different control flow
paths.
It implements the callback interface by implementing call(tuple, boolean). Its call just
saves the tuple and makes it available to others through a public member that returns the tuple.
- Author:
- Pete Wyckoff
- See Also:
- CallbackThread, TupleSpace, Semaphore, TSDispatch
-
Waiter()
-
-
call(String, String, int, SuperTuple, boolean)
- call an application back with a tuple it requested.
-
isException()
- was there an exception for this callback?
-
tuple()
- return the queued up tuple
-
waitFor()
- Wait for the call method to be called
This method calls the semaphore's decrement method to block until
the tuple arrives.
Waiter
public Waiter()
call
public boolean call(String eventName_,
String tsName_,
int sequenceNumber_,
SuperTuple tuple_,
boolean isException_)
- call an application back with a tuple it requested. In the case of an exceptional condition
occurring on the server, isException will be true and the exception will be inside the tuple_,
i.e., the tuple will contain one field that is a TupleSpaceServerException.
This method is called by the callback thread and thus should do something really quick and
return, that is it should not take up lots of time. Typically, it might just queue up
the tuple and isException and wake up some other thread that will do the real processing,
at least that is the intention. This design may need to be changed in which case
one alternative is for this guy to be a thread which gets fired up by
the callback thread. I am not sure as to whether JavaSpaces makes this into a new thread
or not even after looking at the section on it, but I will come back to this. PW
Also, true is returned if this is the last call this callback class is expecting.
For a one time read or in etc this is the case, but for EventHandlers, this is not
the case, they will keep on servicing more and more events. The problem here may be that
I am using one interface for two somewhat different things, although they are only
really different in their longevity. Let's keep it this way until we see how the API should
evolve. PW
- Parameters:
- eventName_ - the name of the event command that caused this call, that is the
name of the client side command of the thread that registered this call, e.g., in the
case of a read, this would be TupleSpace.READ, **not** TupleSpace.WRITE which is the
corresponding command that caused the actaul event.
- tsName_ - the name of the tuple space this command was executed on.
- sequenceNumber_ - the sequenceNumber for this event/command
- tuple_ - the returned tuple or a Tuple with an exception inside
- isException_ - was the command processed normaly or was there an exception
- Returns:
- true if this is the last call this sequence # should be getting otherwise false
- See Also:
- TupleSpace, CallbackThread, TSDispatch
waitFor
public void waitFor()
- Wait for the call method to be called
This method calls the semaphore's decrement method to block until
the tuple arrives.
tuple
public SuperTuple tuple()
- return the queued up tuple
- Returns:
- the tuple that was given to the call method
isException
public boolean isException()
- was there an exception for this callback?
- Returns:
- whether there was an exception
All Packages Class Hierarchy This Package Previous Next Index