1
0
mirror of https://github.com/Oxalide/vsphere-influxdb-go.git synced 2023-10-10 13:36:51 +02:00
vsphere-influxdb-go/vendor/github.com/influxdata/influxdb/pkg/limiter/fixed.go
2017-10-25 20:52:40 +00:00

20 lines
466 B
Go

// Package limiter provides concurrency limiters.
package limiter
// Fixed is a simple channel-based concurrency limiter. It uses a fixed
// size channel to limit callers from proceeding until there is a value available
// in the channel. If all are in-use, the caller blocks until one is freed.
type Fixed chan struct{}
func NewFixed(limit int) Fixed {
return make(Fixed, limit)
}
func (t Fixed) Take() {
t <- struct{}{}
}
func (t Fixed) Release() {
<-t
}