diff --git a/pageserver/src/context.rs b/pageserver/src/context.rs index 24672ad3b1..f5193f45a6 100644 --- a/pageserver/src/context.rs +++ b/pageserver/src/context.rs @@ -96,6 +96,7 @@ use crate::task_mgr::TaskKind; pub struct RequestContext { latency_recording: Option, io_concurrency: Option, + cancel: Option, } trait Propagatable: Default { @@ -160,3 +161,25 @@ mod io_concurrency_propagation { } } + +mod cancellation { + + struct Cancellation { + sources: Vec, + } + + impl Propagatable for Cancellation { + fn propagate(&self, other: &mut Self) { + other.sources.extend(self.sources.iter().map(|tok| tok.child_toke())); + } + } + + impl Cancellation { + async fn cancelled(&self) { + // TODO: this one is quite inefficient, it allocates + // But it's clear something better can be built within this architecture. + futures::future::select_all(self.sources.iter().map(|tok| tok.cancelled())) + } + } + +}