mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-02-03 22:18:39 +00:00
25 lines
331 B
Go
25 lines
331 B
Go
package cli
|
|
|
|
type semaphore interface {
|
|
acquire()
|
|
release()
|
|
}
|
|
|
|
type noopSemaphore struct{}
|
|
|
|
func (n noopSemaphore) acquire() {}
|
|
|
|
func (n noopSemaphore) release() {}
|
|
|
|
type chanSemaphore struct {
|
|
ready chan struct{}
|
|
}
|
|
|
|
func (c *chanSemaphore) acquire() {
|
|
c.ready <- struct{}{}
|
|
}
|
|
|
|
func (c *chanSemaphore) release() {
|
|
<-c.ready
|
|
}
|