From 2a73afc5a781f19c53de56e287da6407baf99bd4 Mon Sep 17 00:00:00 2001 From: phuslu Date: Thu, 4 Jan 2024 02:07:09 +0800 Subject: [PATCH] still update global clock per 100ms --- shard.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/shard.go b/shard.go index bb4fd16..21382cc 100644 --- a/shard.go +++ b/shard.go @@ -155,7 +155,11 @@ func init() { atomic.StoreUint32(&clock, uint32(time.Now().Unix()-unixBase)) go func() { for { - time.Sleep(500 * time.Millisecond) + for i := 0; i < 9; i++ { + time.Sleep(100 * time.Millisecond) + atomic.StoreUint32(&clock, uint32(time.Now().Unix()-unixBase)) + } + time.Sleep(100 * time.Millisecond) atomic.StoreUint32(&clock, uint32(time.Now().Unix()-unixBase)) } }()