dynamo_runtime/runnable.rs
1// SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2// SPDX-License-Identifier: Apache-2.0
3
4//! Runnable Module.
5//!
6//! This module provides a way to run a task in a runtime.
7//!
8
9use std::{
10 pin::Pin,
11 task::{Context, Poll},
12};
13
14pub use anyhow::{Error, Result};
15pub use async_trait::async_trait;
16pub use tokio::task::JoinHandle;
17pub use tokio_util::sync::CancellationToken;
18
19#[async_trait]
20pub trait ExecutionHandle {
21 fn is_finished(&self) -> bool;
22 fn is_cancelled(&self) -> bool;
23 fn cancel(&self);
24 fn cancellation_token(&self) -> CancellationToken;
25 fn handle(self) -> JoinHandle<Result<()>>;
26}