use of com.koushikdutta.async.future.Future in project ion by koush.
the class Ion method getPendingRequestCount.
public int getPendingRequestCount(Object group) {
synchronized (this) {
FutureSet members = inFlight.get(group);
if (members == null)
return 0;
int ret = 0;
for (Future future : members.keySet()) {
if (!future.isCancelled() && !future.isDone())
ret++;
}
return ret;
}
}
use of com.koushikdutta.async.future.Future in project AndroidAsync by koush.
the class AsyncHttpClient method execute.
public <T> SimpleFuture<T> execute(AsyncHttpRequest req, final AsyncParser<T> parser, final RequestCallback<T> callback) {
final FutureAsyncHttpResponse cancel = new FutureAsyncHttpResponse();
final SimpleFuture<T> ret = new SimpleFuture<T>();
execute(req, 0, cancel, new HttpConnectCallback() {
@Override
public void onConnectCompleted(Exception ex, final AsyncHttpResponse response) {
if (ex != null) {
invoke(callback, ret, response, ex, null);
return;
}
invokeConnect(callback, response);
Future<T> parsed = parser.parse(response).setCallback(new FutureCallback<T>() {
@Override
public void onCompleted(Exception e, T result) {
invoke(callback, ret, response, e, result);
}
});
// reparent to the new parser future
ret.setParent(parsed);
}
});
ret.setParent(cancel);
return ret;
}
Aggregations