mirror of
https://github.com/scroll-tech/scroll.git
synced 2026-01-14 00:18:03 -05:00
Co-authored-by: colinlyguo <102356659+colinlyguo@users.noreply.github.com> Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com>
14 lines
239 B
Go
14 lines
239 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; i < times; i++ {
|
|
if run() {
|
|
return
|
|
}
|
|
time.Sleep(time.Millisecond * 500)
|
|
}
|
|
}
|