public class AsynchOpsHelper extends AbstractTucsonAgent
completionEvents
Constructor and Description |
---|
AsynchOpsHelper(java.lang.String id)
Builds an helper given the delegating agent ID
|
Modifier and Type | Method and Description |
---|---|
boolean |
enqueue(AbstractTucsonAction action,
TucsonOperationCompletionListener listener)
Adds an operation to the queue of pending operations, only if the
shutdown operation hasn't been called yet.
|
CompletedOpsQueue |
getCompletedOps()
Gets the queue of completed operations
|
SearchableOpsQueue |
getPendingOps()
Gets the queue of pending operations
|
java.util.concurrent.Semaphore |
getPendingOpsSemaphore()
Gets the pending operations
Semaphore object |
java.util.concurrent.Semaphore |
getShutdownSemaphore()
Gets the
Semaphore object for shutdown
synchronisation |
boolean |
isShutdownGraceful()
Checks whether soft shutdown has been requested
|
boolean |
isShutdownNow()
Checks whether hard shutdown has been requested
|
protected void |
main()
Main execution cycle, user-defined.
|
void |
operationCompleted(AbstractTupleCentreOperation op) |
void |
operationCompleted(ITucsonOperation op) |
void |
shutdownGracefully()
Requests soft shutdown of the helper, that is, shutdown happens only when
the queue of pending operations has been emptied
|
void |
shutdownNow()
Requests hard shutdown of the helper, that is, shutdown happens as soon
as the current operation in execution completes: pending operations are
discarded instead
|
getContext, getTucsonAgentId, go, myName, myNode, myport, say, setContext
public AsynchOpsHelper(java.lang.String id) throws TucsonInvalidAgentIdException
id
- the ID of the agent delegating asynchronous invocation to this
helperTucsonInvalidAgentIdException
- if the given String does not represent a valid TuCSoN agent
identifierpublic final boolean enqueue(AbstractTucsonAction action, TucsonOperationCompletionListener listener)
action
- the TuCSoN operation to execute.listener
- the TuCSoN listener in charge of handling operation completion
asynchronouslytrue
or false
depending on whether the enqueue
operation was successful or notpublic final CompletedOpsQueue getCompletedOps()
public final SearchableOpsQueue getPendingOps()
public final java.util.concurrent.Semaphore getPendingOpsSemaphore()
Semaphore
objectSemaphore
public final java.util.concurrent.Semaphore getShutdownSemaphore()
Semaphore
object for shutdown
synchronisationSemaphore
for shutdown
synchronisationpublic final boolean isShutdownGraceful()
true
or false
depending on whether soft shutdown
has been requested or notpublic final boolean isShutdownNow()
true
or false
depending on whether hard shutdown
has been requested or notpublic void operationCompleted(AbstractTupleCentreOperation op)
operationCompleted
in interface OperationCompletionListener
operationCompleted
in class AbstractTucsonAgent
op
- the operation completedpublic void operationCompleted(ITucsonOperation op)
operationCompleted
in interface TucsonOperationCompletionListener
operationCompleted
in class AbstractTucsonAgent
op
- the TuCSoN operation just completedpublic final void shutdownGracefully()
public final void shutdownNow()
protected final void main()
AbstractTucsonAgent
main
in class AbstractTucsonAgent