Browse Source

TermIndex复位

tags/v1.0.0
zhouzj 4 years ago
parent
commit
2f7a9fa2fe
1 changed files with 5 additions and 6 deletions
  1. +5
    -6
      src/Yitter.IdGenerator/SnowWorkerM1.cs

+ 5
- 6
src/Yitter.IdGenerator/SnowWorkerM1.cs View File

@@ -75,7 +75,6 @@ namespace Yitter.IdGenerator
StartTimeUtc = options.StartTime; StartTimeUtc = options.StartTime;
} }


// 如果没有初始化,则随机一个数值
if (WorkerId < 1) if (WorkerId < 1)
{ {
WorkerId = (ushort)DateTime.Now.Millisecond; WorkerId = (ushort)DateTime.Now.Millisecond;
@@ -104,11 +103,6 @@ namespace Yitter.IdGenerator
{ {
Task.Run(() => Task.Run(() =>
{ {
if (arg.ActionType == 2 && _TermIndex > 10000)
{
_TermIndex = 0;
}
GenAction(arg); GenAction(arg);
}); });
} }
@@ -131,6 +125,11 @@ namespace Yitter.IdGenerator
private void EndOverCostCallBack(in long useTimeTick) private void EndOverCostCallBack(in long useTimeTick)
{ {
if (_TermIndex > 10000)
{
_TermIndex = 0;
}
if (GenAction == null) if (GenAction == null)
{ {
return; return;


Loading…
Cancel
Save