async-sema

Crates.ioasync-sema
lib.rsasync-sema
version0.1.4
sourcesrc
created_at2024-07-19 17:10:00.185533
updated_at2024-07-25 16:15:58.698597
descriptionAsync semaphore library
homepagehttps://github.com/fawdlstty/async-sema-rs
repositoryhttps://github.com/fawdlstty/async-sema-rs
max_upload_size
id1308926
size7,916
Fawdlstty (fawdlstty)

documentation

README

async-sema-rs

version status

Async semaphore library

Manual

Install: Run cargo add async-sema in the project directory

example

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());
Commit count: 0

cargo fmt