public abstract class CallSynchronizer<ID,INPUT,OUTPUT> extends Object
Constructor and Description |
---|
CallSynchronizer()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
abortCall(ID id)
Abort the call with the given ID. it unblocks the call and the
performCall(Object, Object) will throw a
InterruptedException . |
protected abstract void |
operate(ID callerID,
INPUT input)
This method operates the call, it performs the adequate operations to
ensure there will be a response calling on another thread.
|
OUTPUT |
performCall(ID callerID,
INPUT input)
This method is the main method to syncronize the caller thread.
|
void |
performResponse(ID id,
OUTPUT output)
When a response for a call is found, this method should be used to notify
the Caller
Thread waiting for it. |
void |
purge()
When there will be no more responses this method aborts all calls,
|
public OUTPUT performCall(ID callerID, INPUT input) throws InterruptedException
Thread
will be stoped until another thread calls
CallSynchronizer#performResponse(ID, Object)
.callerID
- the Id to identify the call.input
- The input needed to perform the call.InterruptedException
- when the call was aborted by other thread.CallSynchronizer#performResponse(ID, Object)
protected abstract void operate(ID callerID, INPUT input)
callerID
- the call identifierinput
- the input needed for the callpublic void performResponse(ID id, OUTPUT output)
Thread
waiting for it.id
- output
- public void abortCall(ID id)
performCall(Object, Object)
will throw a
InterruptedException
.id
- public void purge()
Copyright © 2015 universAAL Consortium. All Rights Reserved.