handle resolve
This commit is contained in:
parent
4a77f67819
commit
3959732765
1 changed files with 35 additions and 0 deletions
|
@ -448,6 +448,41 @@ final class RpcState {
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleResolve(IncomingRpcMessage message, RpcProtocol.Resolve.Reader resolve) {
|
void handleResolve(IncomingRpcMessage message, RpcProtocol.Resolve.Reader resolve) {
|
||||||
|
|
||||||
|
ClientHook replacement = null;
|
||||||
|
Throwable exc = null;
|
||||||
|
|
||||||
|
switch (resolve.which()) {
|
||||||
|
case CAP:
|
||||||
|
replacement = receiveCap(resolve.getCap(), message.getAttachedFds());
|
||||||
|
break;
|
||||||
|
case EXCEPTION:
|
||||||
|
exc = new RuntimeException(resolve.getException().getReason().toString());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var imp = imports.find(resolve.getPromiseId());
|
||||||
|
if (imp == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var fulfiller = imp.promise;
|
||||||
|
if (fulfiller != null) {
|
||||||
|
if (exc != null) {
|
||||||
|
fulfiller.completeExceptionally(exc);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fulfiller.complete(replacement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (imp.importClient != null) {
|
||||||
|
// It appears this is a valid entry on the import table, but was not expected to be a
|
||||||
|
// promise.
|
||||||
|
assert false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleDisembargo(RpcProtocol.Disembargo.Reader disembargo) {
|
void handleDisembargo(RpcProtocol.Disembargo.Reader disembargo) {
|
||||||
|
|
Loading…
Reference in a new issue