sync::Semaphore — blocking. tokio::sync::Semaphore — async.
sync::Semaphore:
tokio::sync::Semaphore:
1// Blocking2use std::sync::Semaphore;3let sem = Semaphore::new(5);4let _permit = sem.acquire().unwrap();56// Async7use tokio::sync::Semaphore;8let sem = Semaphore::new(5);9let _permit = sem.acquire().await.unwrap();
Key: std for blocking, tokio for async.