V
- return type of the asynchronous call.public abstract class AbstractAsyncCallableWithResources<V> extends Object implements StoppableCallbackCallable<V>
Constructor and Description |
---|
AbstractAsyncCallableWithResources() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
acquireResources()
Open the IO Handle (e.g.
|
V |
call()
This method implements the strategy for the actual IO operation:
|
void |
done(boolean canceled)
Optional callback that subclasses can implement.
|
Exception |
getStopException()
Returns a potential exception that might have been observed while stopping the operation.
|
boolean |
isCalled()
True once the async method was called.
|
boolean |
isStopped()
Check if the IO operation is stopped
|
protected abstract V |
performOperation()
Implements the actual operation.
|
protected abstract void |
releaseResources()
Releases resources acquired by this object.
|
void |
stop()
Stops the I/O operation by closing the I/O handle.
|
protected abstract void |
stopOperation()
This method implements how the operation is stopped.
|
public final V call() throws Exception
1) Acquire resources asynchronously and atomically w.r.t stopping. 2) Performs the operation 3) Releases resources.
protected abstract void acquireResources() throws Exception
Exception
- if there was a problem in acquiring.protected abstract V performOperation() throws Exception
Exception
- if there was a problem in executing the operation.protected abstract void releaseResources() throws Exception
Exception
- if there was a problem in releasing resources.protected abstract void stopOperation() throws Exception
Exception
- on problems during the stopping.public final void stop()
stop
in interface AsyncStoppable
public void done(boolean canceled)
done
in interface AsyncDoneCallback
canceled
- true if the callback is done, but was canceledpublic boolean isCalled()
public boolean isStopped()
isStopped
in interface AsyncStoppable
public Exception getStopException()
getStopException
in interface AsyncStoppable
Copyright © 2014–2018 The Apache Software Foundation. All rights reserved.