mirror of https://bitbucket.org/ausocean/av.git
codecutil: removed unused code
This commit is contained in:
parent
72d56e31ee
commit
eb4a325981
|
@ -52,6 +52,8 @@ func (l *ByteLexer) Lex(dst io.Writer, src io.Reader, t time.Duration) error {
|
||||||
if t < 0 {
|
if t < 0 {
|
||||||
return fmt.Errorf("invalid delay: %v", t)
|
return fmt.Errorf("invalid delay: %v", t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set up delay, make loop instant if t is 0.
|
||||||
var ticker *time.Ticker
|
var ticker *time.Ticker
|
||||||
var zeroTicks chan time.Time
|
var zeroTicks chan time.Time
|
||||||
if t > 0 {
|
if t > 0 {
|
||||||
|
@ -76,28 +78,3 @@ func (l *ByteLexer) Lex(dst io.Writer, src io.Reader, t time.Duration) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
|
||||||
for _, delay := range []time.Duration{0, 10 * time.Millisecond} {
|
|
||||||
t := newTicker(delay)
|
|
||||||
for i := 0; i < 10; i++ {
|
|
||||||
<-t.C
|
|
||||||
fmt.Println(time.Now(), i)
|
|
||||||
}
|
|
||||||
fmt.Println()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var zeroTicks chan time.Time
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
zeroTicks = make(chan time.Time)
|
|
||||||
close(zeroTicks)
|
|
||||||
}
|
|
||||||
|
|
||||||
func newTicker(d time.Duration) *time.Ticker {
|
|
||||||
if d == 0 {
|
|
||||||
return &time.Ticker{C: zeroTicks}
|
|
||||||
}
|
|
||||||
return time.NewTicker(d)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue