19146: Remove unneeded special case checks, explain the needed one.
[arvados.git] / lib / controller / semaphore.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 package controller
6
7 func semaphore(max int) (acquire, release func()) {
8         if max > 0 {
9                 ch := make(chan bool, max)
10                 return func() { ch <- true }, func() { <-ch }
11         }
12         return func() {}, func() {}
13 }