@Override public void onResponse(Call<T> call, Response<T> response) { promise.success(response); }
@Override public void onResponse(Call<T> call, Response<T> response) { if (response.isSuccessful()) { promise.success(response.body()); } else { promise.failure(new HttpException(response)); } }
/** * Completes the promise with a value. * * @param a The value to complete with */ public void success(A a) { this.promise.success(a); }
@Override public boolean complete(T value) { try { promise.success(value); return true; } catch (IllegalStateException e) { return false; } }
@Override public void onNext(HttpResponse o) { promise.success(o); } });
private void completePromise(ActorGateway gateway) { synchronized (lock) { if (!futureActorGateway.isCompleted()) { futureActorGateway.success(gateway); } } }
@Override public Response onCompleted(Response response) { StandaloneAhcWSResponse r = new StandaloneAhcWSResponse(response); scalaPromise.success(r); return response; }
@Override public Response onCompleted(Response response) { StandaloneAhcWSResponse r = new StandaloneAhcWSResponse(response); scalaPromise.success(r); return response; }
private void completePromise(ActorGateway gateway) { synchronized (lock) { if (!futureActorGateway.isCompleted()) { futureActorGateway.success(gateway); } } }
@Override public Response onCompleted(Response response) { scalaPromise.success(new AhcWSResponse(response)); return response; }
private void completePromise(ActorGateway gateway) { synchronized (lock) { if (!futureActorGateway.isCompleted()) { futureActorGateway.success(gateway); } } }
@Override public com.ning.http.client.Response onCompleted(com.ning.http.client.Response response) { final com.ning.http.client.Response ahcResponse = response; scalaPromise.success(new Response(ahcResponse)); return response; } @Override
@Override public void onSuccess(@Nonnull final YangTextSchemaSource result) { try { promise.success(new YangTextSchemaSourceSerializationProxy(result)); } catch (IOException e) { LOG.warn("Unable to read schema source for {}", result.getIdentifier(), e); promise.failure(e); } }
@Override public void notifyLeaderAddress(String leaderAddress, UUID leaderSessionID) { if (leaderAddress != null && !leaderAddress.equals("") && !connectionInfo.isCompleted()) { try { final LeaderConnectionInfo leaderConnectionInfo = new LeaderConnectionInfo(leaderAddress, leaderSessionID); connectionInfo.success(leaderConnectionInfo); } catch (FlinkException e) { connectionInfo.failure(e); } } }
@Override public void onSuccess(YangTextSchemaSource result) { try { promise.success(new YangTextSchemaSourceSerializationProxy(result)); } catch (IOException e) { LOG.warn("Unable to read schema source for {}", result.getIdentifier(), e); promise.failure(e); } }
@Benchmark public Void ensurePromiseN() throws Exception { Promise<Void> p = Promise.<Void>apply(); Future<Void> f = p.future(); for (int i = 0; i < N.n; i++) f = f.transform(ensureF, ec); p.success(null); return Await.result(f, inf); }
@Benchmark public String setValueN() throws Exception { Promise<String> p = Promise.<String>apply(); Future<String> f = p.future(); for (int i = 0; i < N.n; i++) f = f.map(mapF, ec); p.success(string); return Await.result(f, inf); }
@Benchmark public String mapPromise() throws Exception { Promise<String> p = Promise.<String>apply(); Future<String> f = p.future().map(mapF, ec); p.success(string); return Await.result(f, inf); }
@Benchmark public String mapPromiseN() throws Exception { Promise<String> p = Promise.<String>apply(); Future<String> f = p.future(); for (int i = 0; i < N.n; i++) f = f.map(mapF, ec); p.success(string); return Await.result(f, inf); }
@Benchmark public String flatMapPromise() throws Exception { Promise<String> p = Promise.<String>apply(); Future<String> f = p.future().flatMap(flatMapF, ec); p.success(string); return Await.result(f, inf); }