Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

start trying to implement tail_call() and set_pipeline() #380

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions capnp-rpc/src/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@
}
}

fn set_pipeline(&mut self, pipeline: Box<dyn PipelineHook>) {

Check warning on line 129 in capnp-rpc/src/local.rs

View workflow job for this annotation

GitHub Actions / lint

unused variable: `pipeline`

warning: unused variable: `pipeline` --> capnp-rpc/src/local.rs:129:32 | 129 | fn set_pipeline(&mut self, pipeline: Box<dyn PipelineHook>) { | ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_pipeline` | = note: `#[warn(unused_variables)]` on by default
todo!()
}

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
16 changes: 14 additions & 2 deletions capnp-rpc/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2140,6 +2140,7 @@
variant: Option<ResultsVariant>,
redirect_results: bool,
answer_id: AnswerId,
tail_call_pipeline_fulfiller: Option<oneshot::Sender<any_pointer::Pipeline>>,

Check warning on line 2143 in capnp-rpc/src/rpc.rs

View workflow job for this annotation

GitHub Actions / lint

field `tail_call_pipeline_fulfiller` is never read

warning: field `tail_call_pipeline_fulfiller` is never read --> capnp-rpc/src/rpc.rs:2143:5 | 2135 | struct ResultsInner<VatId> | ------------ field in this struct ... 2143 | tail_call_pipeline_fulfiller: Option<oneshot::Sender<any_pointer::Pipeline>>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default
finish_received: Rc<Cell<bool>>,
}

Expand Down Expand Up @@ -2203,6 +2204,7 @@
redirect_results,
answer_id,
finish_received,
tail_call_pipeline_fulfiller: None,
}),
results_done_fulfiller: Some(fulfiller),
}
Expand Down Expand Up @@ -2250,8 +2252,18 @@
}
}

fn tail_call(self: Box<Self>, _request: Box<dyn RequestHook>) -> Promise<(), Error> {
unimplemented!()
fn set_pipeline(&mut self, pipeline: Box<dyn PipelineHook>) {

Check warning on line 2255 in capnp-rpc/src/rpc.rs

View workflow job for this annotation

GitHub Actions / lint

unused variable: `pipeline`

warning: unused variable: `pipeline` --> capnp-rpc/src/rpc.rs:2255:32 | 2255 | fn set_pipeline(&mut self, pipeline: Box<dyn PipelineHook>) { | ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_pipeline`
todo!()
}

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);

Check warning on line 2264 in capnp-rpc/src/rpc.rs

View workflow job for this annotation

GitHub Actions / lint

unused variable: `pipeline`

warning: unused variable: `pipeline` --> capnp-rpc/src/rpc.rs:2264:23 | 2264 | let (promise, pipeline) = self.direct_tail_call(request); | ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_pipeline`
// TODO somehow send pipeline to tail_call_pipeline_fulfiller
promise
}

fn direct_tail_call(
Expand Down
11 changes: 10 additions & 1 deletion capnp/src/capability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
#[cfg(feature = "alloc")]
impl<T> Results<T>
where
T: Owned,
T: Owned + Pipelined,
{
pub fn new(hook: alloc::boxed::Box<dyn ResultsHook>) -> Self {
Self {
Expand All @@ -263,6 +263,15 @@
pub fn set(&mut self, other: T::Reader<'_>) -> crate::Result<()> {
self.hook.get().unwrap().set_as(other)
}

pub fn set_pipeline(&mut self, pipeline: T::Pipeline) {

Check warning on line 267 in capnp/src/capability.rs

View workflow job for this annotation

GitHub Actions / lint

unused variable: `pipeline`

warning: unused variable: `pipeline` --> capnp/src/capability.rs:267:36 | 267 | pub fn set_pipeline(&mut self, pipeline: T::Pipeline) { | ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_pipeline` | = note: `#[warn(unused_variables)]` on by default
// How do we get a PipelineHook out of `pipeline`?
//self.hook.set_pipeline(pipeline)
}

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
6 changes: 6 additions & 0 deletions capnp/src/private/capability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,16 @@ impl Clone for alloc::boxed::Box<dyn ClientHook> {
pub trait ResultsHook {
fn get(&mut self) -> crate::Result<any_pointer::Builder<'_>>;
fn allow_cancellation(&self);

fn tail_call(
self: alloc::boxed::Box<Self>,
request: alloc::boxed::Box<dyn RequestHook>,
) -> Promise<(), crate::Error>;

fn set_pipeline(&mut self, pipeline: Box<dyn PipelineHook>);

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

fn direct_tail_call(
self: alloc::boxed::Box<Self>,
request: alloc::boxed::Box<dyn RequestHook>,
Expand Down
Loading