Skip to content

Commit

Permalink
start trying to implement tail_call() and set_pipeline()
Browse files Browse the repository at this point in the history
  • Loading branch information
dwrensha committed Mar 2, 2023
1 parent 6c2d95b commit 39b91ea
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
4 changes: 4 additions & 0 deletions capnp-rpc/src/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ impl ResultsHook for Results {
}
}

fn on_tail_call(&mut self) -> Promise<any_pointer::Pipeline, crate::Error> {
todo!()
}

fn tail_call(self: Box<Self>, _request: Box<dyn RequestHook>) -> Promise<(), Error> {
unimplemented!()
}
Expand Down
12 changes: 10 additions & 2 deletions capnp-rpc/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2176,6 +2176,7 @@ where
variant: Option<ResultsVariant>,
redirect_results: bool,
answer_id: AnswerId,
tail_call_pipeline_fulfiller: Option<oneshot::Sender<any_pointer::Pipeline>>,
finish_received: Rc<Cell<bool>>,
}

Expand Down Expand Up @@ -2239,6 +2240,7 @@ where
redirect_results,
answer_id,
finish_received,
tail_call_pipeline_fulfiller: None,
}),
results_done_fulfiller: Some(fulfiller),
}
Expand Down Expand Up @@ -2293,8 +2295,14 @@ impl<VatId> ResultsHook for Results<VatId> {
}
}

fn tail_call(self: Box<Self>, _request: Box<dyn RequestHook>) -> Promise<(), Error> {
unimplemented!()
fn on_tail_call(&mut self) -> Promise<any_pointer::Pipeline, crate::Error> {
todo!()
}

fn tail_call(self: Box<Self>, request: Box<dyn RequestHook>) -> Promise<(), Error> {
let (promise, pipeline) = self.direct_tail_call(request);
// TODO somehow send pipeline to tail_call_pipeline_fulfiller
promise
}

fn direct_tail_call(
Expand Down
6 changes: 6 additions & 0 deletions capnp/src/capability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ where
pub fn set(&mut self, other: T::Reader<'_>) -> crate::Result<()> {
self.hook.get().unwrap().set_as(other)
}

pub fn tail_call<SubParams>(self, tail_request: Request<SubParams, T>)
-> Promise<(), Error>
{
self.hook.tail_call(tail_request.hook)
}
}

pub trait FromTypelessPipeline {
Expand Down
3 changes: 3 additions & 0 deletions capnp/src/private/capability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ impl Clone for Box<dyn ClientHook> {
pub trait ResultsHook {
fn get(&mut self) -> crate::Result<any_pointer::Builder<'_>>;
fn allow_cancellation(&self);

fn on_tail_call(&mut self) -> Promise<any_pointer::Pipeline, crate::Error>;

fn tail_call(self: Box<Self>, request: Box<dyn RequestHook>) -> Promise<(), crate::Error>;
fn direct_tail_call(
self: Box<Self>,
Expand Down

0 comments on commit 39b91ea

Please sign in to comment.