mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-13 00:12:54 +00:00
It's mostly responsible for waking, retrying, and caching. A new, thin wrapper around compute_once will be PGLB's entry point
15 lines
386 B
Rust
15 lines
386 B
Rust
use std::pin::pin;
|
|
|
|
use futures::future::{Either, select};
|
|
use tokio_util::sync::CancellationToken;
|
|
|
|
pub async fn run_until_cancelled<F: Future>(
|
|
f: F,
|
|
cancellation_token: &CancellationToken,
|
|
) -> Option<F::Output> {
|
|
match select(pin!(f), pin!(cancellation_token.cancelled())).await {
|
|
Either::Left((f, _)) => Some(f),
|
|
Either::Right(((), _)) => None,
|
|
}
|
|
}
|