fix golint issues in core/syncx (#526)

This commit is contained in:
Kevin Wan
2021-02-28 16:16:22 +08:00
committed by GitHub
parent f02711a9cb
commit 490241d639
18 changed files with 73 additions and 2 deletions

View File

@@ -7,17 +7,19 @@ import (
"github.com/tal-tech/go-zero/core/timex"
)
// A Cond is used to wait for conditions.
type Cond struct {
signal chan lang.PlaceholderType
}
// NewCond returns a Cond.
func NewCond() *Cond {
return &Cond{
signal: make(chan lang.PlaceholderType),
}
}
// WaitWithTimeout wait for signal return remain wait time or timed out
// WaitWithTimeout wait for signal return remain wait time or timed out.
func (cond *Cond) WaitWithTimeout(timeout time.Duration) (time.Duration, bool) {
timer := time.NewTimer(timeout)
defer timer.Stop()
@@ -33,7 +35,7 @@ func (cond *Cond) WaitWithTimeout(timeout time.Duration) (time.Duration, bool) {
}
}
// Wait for signal
// Wait waits for signals.
func (cond *Cond) Wait() {
<-cond.signal
}