adk_audio/pipeline/
handle.rs1use std::sync::Arc;
4
5use tokio::sync::{RwLock, mpsc, oneshot};
6
7use crate::pipeline::types::{PipelineInput, PipelineMetrics, PipelineOutput};
8
9pub struct PipelineHandle {
14 pub input_tx: mpsc::Sender<PipelineInput>,
16 pub output_rx: mpsc::Receiver<PipelineOutput>,
18 pub metrics: Arc<RwLock<PipelineMetrics>>,
20 shutdown_tx: Option<oneshot::Sender<()>>,
22}
23
24impl PipelineHandle {
25 pub(crate) fn new(
27 input_tx: mpsc::Sender<PipelineInput>,
28 output_rx: mpsc::Receiver<PipelineOutput>,
29 metrics: Arc<RwLock<PipelineMetrics>>,
30 shutdown_tx: oneshot::Sender<()>,
31 ) -> Self {
32 Self { input_tx, output_rx, metrics, shutdown_tx: Some(shutdown_tx) }
33 }
34
35 pub fn shutdown(&mut self) {
37 if let Some(tx) = self.shutdown_tx.take() {
38 let _ = tx.send(());
39 }
40 }
41}