Modifier and Type | Method and Description |
---|---|
void |
cancel()
Cancels this Call.
|
Call |
clone()
Clones the current Call into a new instance with the same parameters and returns it.
|
void |
enqueue(Callback callback)
Enqueues the Call on another thread.
|
Response |
enqueueAndWait()
Enqueues the call on another thread and blocks the calling thread
until the Response is received or an exception is thrown.
|
Response |
enqueueAndWait(long timeout,
java.util.concurrent.TimeUnit timeUnit)
Enqueues the call on another thread and blocks the calling thread
for at most the given time period after
which provides the Response if ready.
|
Response |
execute()
Executes the call.
|
boolean |
isCancelled()
Returns a boolean to show if the Call has been cancelled already.
|
boolean |
isExecuted()
Returns a boolean to show if the Call has been executed already.
|
Request |
request()
Provides the Request of this call
|
Response execute() throws java.io.IOException
Note this method executes on the thread on which it's called an blocks until it's done or an exception is thrown.
java.io.IOException
- on failed IO operationsResponse enqueueAndWait() throws java.io.IOException, java.lang.InterruptedException
java.io.IOException
- on failed IO operationsjava.lang.InterruptedException
- if the thread is interrupted during executionResponse enqueueAndWait(long timeout, java.util.concurrent.TimeUnit timeUnit) throws java.io.IOException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
Note that you are not guaranteed to receive the expected Response within the time period specified.
timeout
- The maximum period of time after which the Call should try to retrieve the resulttimeUnit
- The unit in which you've provided the time periodjava.io.IOException
- on failed IO operationsjava.lang.InterruptedException
- on interruption of the computationjava.util.concurrent.TimeoutException
- if the Response was not received within the time periodvoid enqueue(Callback callback)
Callback.onResponse(Call, Response) will be called if all goes well Callback.onFailure(Call, IOException) will be called in case there was an exception during the call
callback
- The Callback to be fired upon completion or an error.boolean isExecuted()
Note that a Call can only be executed once
void cancel()
boolean isCancelled()