use tokio::spawn;
use tokio::sync::mpsc::{channel, Sender};
use tokio::task::JoinHandle;

use crate::chopper::types::Row;
use crate::driver::splitter::Splitter;

pub async fn drive_splitter(
    output_txs: Vec<Sender<Box<Row>>>,
) -> (Sender<Box<Row>>, JoinHandle<()>) {
    let (splitter_tx, splitter_rx) = channel(256);
    let mut splitter = Splitter::new(splitter_rx, output_txs);
    (splitter_tx, spawn(async move { splitter.run().await }))
}
