INNER CODE UNIT · Go
NewGate
spegel-org/spegel · internal/channel/gate.go:13
func NewGate() *Gate {
return &Gate{
state: false,
}
}
// State returns true when the gate is open and false when closed.
func (g *Gate) State() bool {
g.mu.RLock()
defer g.mu.RUnlock()
return g.state
}
// Open opens the gate and informs any waiters.
func (g *Gate) Open() {
g.set(true)
}