From 214ce815bc546fb728271dc5b223dddee3d9569a Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Wed, 22 Jan 2025 19:19:42 +0100 Subject: [PATCH] sketch cancellation --- pageserver/src/context.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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())) + } + } + +}