Adjust initial coordinator delay

pull/116/head
Junegunn Choi 10 years ago
parent efec9acd6f
commit f401c42f9c

@ -7,7 +7,8 @@ import (
"time" "time"
) )
const COORDINATOR_DELAY time.Duration = 100 * time.Millisecond const COORDINATOR_DELAY_MAX time.Duration = 100 * time.Millisecond
const COORDINATOR_DELAY_STEP time.Duration = 10 * time.Millisecond
func initProcs() { func initProcs() {
runtime.GOMAXPROCS(runtime.NumCPU()) runtime.GOMAXPROCS(runtime.NumCPU())
@ -151,8 +152,11 @@ func Run(options *Options) {
} }
} }
}) })
if ticks > 3 && delay && reading { if delay && reading {
time.Sleep(COORDINATOR_DELAY) dur := DurWithin(
time.Duration(ticks)*COORDINATOR_DELAY_STEP,
0, COORDINATOR_DELAY_MAX)
time.Sleep(dur)
} }
} }
} }

@ -1,5 +1,7 @@
package fzf package fzf
import "time"
func Max(first int, items ...int) int { func Max(first int, items ...int) int {
max := first max := first
for _, item := range items { for _, item := range items {
@ -19,3 +21,14 @@ func Min(first int, items ...int) int {
} }
return min return min
} }
func DurWithin(
val time.Duration, min time.Duration, max time.Duration) time.Duration {
if val < min {
return min
}
if val > max {
return max
}
return val
}

Loading…
Cancel
Save