std::semaphoreCounting semaphore for concurrency control.
Limit the number of concurrent actors or tasks that can access a shared resource.
import std::semaphore;
fn main() {
let sem = semaphore.new(3);
sem.acquire();
// critical section
sem.release();
sem.free();
}
newCreate a new counting semaphore with the given number of permits.
let sem = semaphore.new(5);
SemaphoreAn opaque counting semaphore handle.
Created by semaphore.new(count). Must be freed with free() when
no longer needed to avoid leaking memory.
SemaphoreMethodsMethods available on a Semaphore.