github.com/abiosoft/semaphore@v0.0.0-20240818083615-bc6b5b10c137/README.md (about) 1 2 semaphore 3 ========= 4 5 Semaphore in Go 6 7 [![Build Status](https://travis-ci.org/abiosoft/semaphore.svg?branch=master)](https://travis-ci.org/abiosoft/semaphore) 8 [![GoDoc](https://godoc.org/github.com/abiosoft/semaphore?status.svg)](https://godoc.org/github.com/abiosoft/semaphore) 9 [![Go Report Card](https://goreportcard.com/badge/github.com/abiosoft/semaphore)](https://goreportcard.com/report/github.com/abiosoft/semaphore) 10 11 ### Usage 12 Initiate 13 ```go 14 import "github.com/abiosoft/semaphore" 15 ... 16 sem := semaphore.New(5) // new semaphore with 5 permits 17 ``` 18 Acquire 19 ```go 20 sem.Acquire() // one 21 sem.AcquireMany(n) // multiple 22 sem.AcquireWithin(n, time.Second * 5) // timeout after 5 sec 23 sem.AcquireContext(ctx, n) // acquire with context 24 ``` 25 Release 26 ```go 27 sem.Release() // one 28 sem.ReleaseMany(n) // multiple 29 ``` 30 31 ### documentation 32 33 http://godoc.org/github.com/abiosoft/semaphore