From 6d58535a9193fa9b1683bc562a4939e0d17ad4fe Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 29 Jun 2024 20:49:08 +0800 Subject: [PATCH] 1 --- sysutils.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sysutils.go b/sysutils.go index 1cf83cb..50f71f7 100644 --- a/sysutils.go +++ b/sysutils.go @@ -335,6 +335,20 @@ func AdjustRangeValue[T int | int32 | int64 | float32 | float64](value T, minV T return value } +func CreateCondTimer(ch chan int64, cond *sync.Cond) { + var waitSecond int64 = 10 + for { + select { + case waitSecond = <-ch: + if waitSecond < 10 { + waitSecond = 10 + } + case <-time.After(time.Second * time.Duration(waitSecond)): + cond.Broadcast() + } + } +} + func IsDebug() bool { return true }