alttch / tokio-task-pool

Task pool for Tokio Runtime
MIT License
6 stars 0 forks source link

set bounded number lower task numbers will cause problem #2

Open whtgg opened 10 months ago

whtgg commented 10 months ago

let pool = Pool::bounded(3); let counter = Arc::new(AtomicUsize::new(0)); for _ in 1..=5 { let counter_c = counter.clone(); pool.spawn(async move { sleep(Duration::from_secs(3)).await; counter_c.fetch_add(1, Ordering::SeqCst); }) .await .unwrap(); } sleep(Duration::from_secs(3)).await; // println!("{}",counter.load(Ordering::SeqCst)); assert_eq!(counter.load(Ordering::SeqCst), 5);

divi255 commented 10 months ago

Good day,

I tested the example, the behaviour looks fine. Could you please explain where the problem is?