Skip to content

Instantly share code, notes, and snippets.

View CarlosLanderas's full-sized avatar

Carlos Landeras CarlosLanderas

View GitHub Profile
@CarlosLanderas
CarlosLanderas / main.rs
Last active May 6, 2021 07:50
Rust channel threads with cancellation sample
use anyhow::Result;
use std::sync::Arc;
use std::time::Duration;
#[tokio::main]
async fn main() -> Result<()> {
let (tx, rx) = std::sync::mpsc::channel();
let cts = Arc::new(cancellation::CancellationTokenSource::new());
let cts_clone = cts.clone();