package gate
import "golang.org/x/net/internal/gate"
Package gate contains an alternative condition variable.
Index ¶
Types ¶
type Gate ¶
type Gate struct {
// contains filtered or unexported fields
}
A Gate is a monitor (mutex + condition variable) with one bit of state.
The condition may be either set or unset. Lock operations may be unconditional, or wait for the condition to be set. Unlock operations record the new state of the condition.
func New ¶
New returns a new, unlocked gate.
func (*Gate) Lock ¶
Lock acquires the gate unconditionally. It reports whether the condition is set.
func (*Gate) LockIfSet ¶
LockIfSet acquires the gate if and only if the condition is set.
func (*Gate) Unlock ¶
Unlock sets the condition and releases the gate.
func (*Gate) WaitAndLock ¶
WaitAndLock waits until the condition is set before acquiring the gate. If the context expires, WaitAndLock returns an error and does not acquire the gate.
Source Files ¶
gate.go
- Version
- v0.35.0 (latest)
- Published
- Feb 10, 2025
- Platform
- linux/amd64
- Imports
- 1 packages
- Last checked
- 5 hours ago –
Tools for package owners.