public abstract class QCloudTask<T>
extends java.lang.Object
implements java.util.concurrent.Callable<T>
限定符和类型 | 类和说明 |
---|---|
static interface |
QCloudTask.OnRequestWeightListener |
限定符和类型 | 字段和说明 |
---|---|
static int |
PRIORITY_HIGH |
static int |
PRIORITY_LOW |
protected static int |
PRIORITY_NORMAL |
static int |
STATE_COMPLETE |
static int |
STATE_EXECUTING |
static int |
STATE_QUEUEING |
static int |
WEIGHT_HIGH |
static int |
WEIGHT_LOW |
static int |
WEIGHT_NORMAL |
构造器和说明 |
---|
QCloudTask(java.lang.String identifier,
java.lang.Object tag) |
限定符和类型 | 方法和说明 |
---|---|
QCloudTask<T> |
addProgressListener(QCloudProgressListener progressListener) |
QCloudTask<T> |
addProgressListeners(java.util.List<QCloudProgressListener> progressListeners) |
QCloudTask<T> |
addResultListener(QCloudResultListener<T> resultListener) |
QCloudTask<T> |
addResultListeners(java.util.List<QCloudResultListener<T>> resultListeners) |
QCloudTask<T> |
addStateListener(QCloudTaskStateListener stateListener) |
QCloudTask<T> |
addStateListeners(java.util.List<QCloudTaskStateListener> stateListeners) |
T |
call()
Computes a result, or throws an exception if unable to do so.
|
void |
cancel() |
bolts.Task<T> |
cast() |
protected abstract T |
execute() |
T |
executeNow() |
void |
executeNowSilently() |
java.util.List<QCloudProgressListener> |
getAllProgressListeners() |
java.util.List<QCloudResultListener<T>> |
getAllResultListeners() |
java.util.List<QCloudTaskStateListener> |
getAllStateListeners() |
int |
getDownloadMaxThreadCount() |
java.lang.Exception |
getException() |
java.lang.String |
getIdentifier() |
T |
getResult() |
int |
getState()
获取任务执行状态
|
java.lang.Object |
getTag() |
int |
getUploadMaxThreadCount() |
int |
getWeight() |
boolean |
isCanceled()
任务是否已经取消
|
boolean |
isCompleted()
任务是否执行完成
|
boolean |
isEnableTraffic() |
boolean |
isExecuting()
任务是否正在执行
|
QCloudTask<T> |
observeOn(java.util.concurrent.Executor executor) |
protected void |
onFailure() |
protected void |
onProgress(long complete,
long target) |
protected void |
onStateChanged(int newState) |
protected void |
onSuccess() |
void |
removeAllListeners() |
QCloudTask<T> |
removeProgressListener(QCloudProgressListener progressListener) |
QCloudTask<T> |
removeResultListener(QCloudResultListener<T> resultListener) |
QCloudTask<T> |
removeStateListener(QCloudTaskStateListener stateListener) |
protected QCloudTask<T> |
scheduleOn(java.util.concurrent.Executor executor,
bolts.CancellationTokenSource cancellationTokenSource) |
protected QCloudTask<T> |
scheduleOn(java.util.concurrent.Executor executor,
bolts.CancellationTokenSource cancellationTokenSource,
int priority) |
void |
setDownloadMaxThreadCount(int downloadMaxThreadCount) |
void |
setOnRequestWeightListener(QCloudTask.OnRequestWeightListener onRequestWeightListener) |
void |
setTransferThreadControl(boolean enableTraffic) |
void |
setUploadMaxThreadCount(int uploadMaxThreadCount) |
public static final int STATE_QUEUEING
public static final int STATE_EXECUTING
public static final int STATE_COMPLETE
public static final int PRIORITY_LOW
protected static final int PRIORITY_NORMAL
public static final int PRIORITY_HIGH
public static final int WEIGHT_LOW
public static final int WEIGHT_NORMAL
public static final int WEIGHT_HIGH
public final bolts.Task<T> cast()
public final T executeNow() throws QCloudClientException, QCloudServiceException
public final void executeNowSilently()
protected QCloudTask<T> scheduleOn(java.util.concurrent.Executor executor, bolts.CancellationTokenSource cancellationTokenSource)
protected QCloudTask<T> scheduleOn(java.util.concurrent.Executor executor, bolts.CancellationTokenSource cancellationTokenSource, int priority)
public void cancel()
public void setTransferThreadControl(boolean enableTraffic)
public boolean isEnableTraffic()
public int getUploadMaxThreadCount()
public void setUploadMaxThreadCount(int uploadMaxThreadCount)
public int getDownloadMaxThreadCount()
public void setDownloadMaxThreadCount(int downloadMaxThreadCount)
public final boolean isCanceled()
public final boolean isExecuting()
public final boolean isCompleted()
public final int getState()
STATE_QUEUEING
;
STATE_EXECUTING
;
STATE_COMPLETE
public T call() throws java.lang.Exception
java.util.concurrent.Callable
call
在接口中 java.util.concurrent.Callable<T>
java.lang.Exception
- if unable to compute a resultprotected abstract T execute() throws QCloudClientException, QCloudServiceException
public final QCloudTask<T> observeOn(java.util.concurrent.Executor executor)
public final QCloudTask<T> addResultListener(QCloudResultListener<T> resultListener)
public final QCloudTask<T> addResultListeners(java.util.List<QCloudResultListener<T>> resultListeners)
public final QCloudTask<T> removeResultListener(QCloudResultListener<T> resultListener)
public final void removeAllListeners()
public final java.util.List<QCloudResultListener<T>> getAllResultListeners()
public final java.util.List<QCloudProgressListener> getAllProgressListeners()
public final java.util.List<QCloudTaskStateListener> getAllStateListeners()
public final QCloudTask<T> addProgressListener(QCloudProgressListener progressListener)
public final QCloudTask<T> addProgressListeners(java.util.List<QCloudProgressListener> progressListeners)
public final QCloudTask<T> removeProgressListener(QCloudProgressListener progressListener)
public final QCloudTask<T> addStateListener(QCloudTaskStateListener stateListener)
public final QCloudTask<T> addStateListeners(java.util.List<QCloudTaskStateListener> stateListeners)
public final QCloudTask<T> removeStateListener(QCloudTaskStateListener stateListener)
public T getResult()
public java.lang.Exception getException()
protected void onSuccess()
protected void onFailure()
protected void onProgress(long complete, long target)
protected void onStateChanged(int newState)
public final java.lang.String getIdentifier()
public final java.lang.Object getTag()
public int getWeight()
public void setOnRequestWeightListener(QCloudTask.OnRequestWeightListener onRequestWeightListener)