new style resolve switch

This commit is contained in:
Vaci Koblizek 2020-11-26 15:17:39 +00:00
parent 772108ff12
commit 6326f965ab

View file

@ -1561,7 +1561,6 @@ final class RpcState<VatId> {
*/ */
RpcPipeline(QuestionRef questionRef) { RpcPipeline(QuestionRef questionRef) {
this(questionRef, null); this(questionRef, null);
// TODO implement tail calls...
} }
@Override @Override
@ -1569,30 +1568,30 @@ final class RpcState<VatId> {
// TODO avoid conversion to/from ArrayList? // TODO avoid conversion to/from ArrayList?
var key = new ArrayList<>(Arrays.asList(ops)); var key = new ArrayList<>(Arrays.asList(ops));
var hook = this.clientMap.computeIfAbsent(key, k -> { return this.clientMap.computeIfAbsent(key, k -> {
switch (state) { return switch (state) {
case WAITING: { case WAITING -> {
var pipelineClient = new PipelineClient(this.questionRef, ops); var pipelineClient = new PipelineClient(this.questionRef, ops);
if (this.redirectLater == null) { if (this.redirectLater == null) {
// This pipeline will never get redirected, so just return the PipelineClient. // This pipeline will never get redirected, so just return the PipelineClient.
return pipelineClient; yield pipelineClient;
} }
assert this.resolveSelf != null; assert this.resolveSelf != null;
var resolutionPromise = this.resolveSelf.thenApply( var resolutionPromise = this.resolveSelf.thenApply(
response -> response.getResults().getPipelinedCap(ops)); response -> response.getResults().getPipelinedCap(ops));
return new PromiseClient(pipelineClient, resolutionPromise, null); yield new PromiseClient(pipelineClient, resolutionPromise, null);
} }
case RESOLVED -> {
case RESOLVED:
assert this.resolved != null; assert this.resolved != null;
return this.resolved.getResults().getPipelinedCap(ops); yield this.resolved.getResults().getPipelinedCap(ops);
default:
return Capability.newBrokenCap(broken);
} }
case BROKEN -> {
assert this.broken != null;
yield Capability.newBrokenCap(broken);
}
};
}); });
return hook;
} }
@Override @Override