package
0.3.0
Repository: https://github.com/shevaxu/golang.git
Documentation: pkg.go.dev

# README

Semaphore

For Bounding resource use.

s := semaphore.NewSemaphore(10)

go func() {
    ctx := context.Background() // for cancellation
    if s.Obtain(ctx) {
        defer s.Release()
        // do whatever 
    }
}()

For weighted semaphore, see this implementation.