diff --git a/Go/source/idgen/SnowWorkerM1.go b/Go/source/idgen/SnowWorkerM1.go index cf28b62..e5b5e94 100644 --- a/Go/source/idgen/SnowWorkerM1.go +++ b/Go/source/idgen/SnowWorkerM1.go @@ -232,6 +232,7 @@ func (m1 *SnowWorkerM1) GetCurrentTimeTick() int64 { func (m1 *SnowWorkerM1) GetNextTimeTick() int64 { tempTimeTicker := m1.GetCurrentTimeTick() for tempTimeTicker <= m1._LastTimeTick { + time.Sleep(time.Duration(1) * time.Millisecond) tempTimeTicker = m1.GetCurrentTimeTick() } return tempTimeTicker diff --git a/Go/source/idgen/YitIdHelper.go b/Go/source/idgen/YitIdHelper.go index 6226f60..9142f1b 100644 --- a/Go/source/idgen/YitIdHelper.go +++ b/Go/source/idgen/YitIdHelper.go @@ -1,3 +1,10 @@ +/* + * 版权属于:yitter(yitter@126.com) + * 代码编辑:guoyahao + * 代码修订:yitter + * 开源地址:https://github.com/yitter/idgenerator + */ + package idgen import ( @@ -17,14 +24,14 @@ func SetIdGenerator(options *IdGeneratorOptions) { // NextId . func NextId() int64 { - if idGenerator == nil { - singletonMutex.Lock() - defer singletonMutex.Unlock() - if idGenerator == nil { - options := NewIdGeneratorOptions(1) - idGenerator = NewDefaultIdGenerator(options) - } - } + //if idGenerator == nil { + // singletonMutex.Lock() + // defer singletonMutex.Unlock() + // if idGenerator == nil { + // options := NewIdGeneratorOptions(1) + // idGenerator = NewDefaultIdGenerator(options) + // } + //} return idGenerator.NewLong() } diff --git a/Go/source/regworkerid/reghelper.go b/Go/source/regworkerid/reghelper.go index b974719..b3325ab 100644 --- a/Go/source/regworkerid/reghelper.go +++ b/Go/source/regworkerid/reghelper.go @@ -1,3 +1,8 @@ +/* + * 鐗堟潈灞炰簬锛歽itter(yitter@126.com) + * 寮婧愬湴鍧锛歨ttps://github.com/yitter/idgenerator + */ + package regworkerid import (