From 2f7a9fa2fe1f1dbe49c0b06061feb5a07c306f5f Mon Sep 17 00:00:00 2001 From: zhouzj Date: Thu, 11 Mar 2021 16:52:15 +0800 Subject: [PATCH] =?UTF-8?q?TermIndex=E5=A4=8D=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Yitter.IdGenerator/SnowWorkerM1.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Yitter.IdGenerator/SnowWorkerM1.cs b/src/Yitter.IdGenerator/SnowWorkerM1.cs index ec9446b..4f08cdd 100644 --- a/src/Yitter.IdGenerator/SnowWorkerM1.cs +++ b/src/Yitter.IdGenerator/SnowWorkerM1.cs @@ -75,7 +75,6 @@ namespace Yitter.IdGenerator StartTimeUtc = options.StartTime; } - // 如果没有初始化,则随机一个数值 if (WorkerId < 1) { WorkerId = (ushort)DateTime.Now.Millisecond; @@ -104,11 +103,6 @@ namespace Yitter.IdGenerator { Task.Run(() => { - if (arg.ActionType == 2 && _TermIndex > 10000) - { - _TermIndex = 0; - } - GenAction(arg); }); } @@ -131,6 +125,11 @@ namespace Yitter.IdGenerator private void EndOverCostCallBack(in long useTimeTick) { + if (_TermIndex > 10000) + { + _TermIndex = 0; + } + if (GenAction == null) { return;