| Crates.io | async-sema |
| lib.rs | async-sema |
| version | 0.1.4 |
| created_at | 2024-07-19 17:10:00.185533+00 |
| updated_at | 2024-07-25 16:15:58.698597+00 |
| description | Async semaphore library |
| homepage | https://github.com/fawdlstty/async-sema-rs |
| repository | https://github.com/fawdlstty/async-sema-rs |
| max_upload_size | |
| id | 1308926 |
| size | 7,916 |
Async semaphore library
Install: Run cargo add async-sema in the project directory
use async_sema::Semaphore;
let s = Semaphore::new(2);
// async acquire
s.acquire().await;
s.batch_acquire(1).await;
// instant acquire
let a = s.try_acquire().unwrap();
assert!(s.try_acquire().is_none());
s.add_permits(1);
assert!(s.try_acquire().is_some());