mirror of
https://github.com/scroll-tech/scroll.git
synced 2026-01-14 08:28:02 -05:00
14 lines
254 B
Go
14 lines
254 B
Go
package utils
|
|
|
|
import "time"
|
|
|
|
// TryTimes try run several times until the function return true.
|
|
func TryTimes(times int, run func() bool) {
|
|
for i := 0; times == -1 || i < times; i++ {
|
|
if run() {
|
|
return
|
|
}
|
|
time.Sleep(time.Millisecond * 500)
|
|
}
|
|
}
|