Browse Source

auto commit

tags/v1.3.1
yitter 2 years ago
parent
commit
5e24340526
2 changed files with 10 additions and 4 deletions
  1. +1
    -1
      C#.NET/source/Yitter.IdGenTest/Program.cs
  2. +9
    -3
      C#.NET/source/Yitter.IdGenerator/YitIdHelper.cs

+ 1
- 1
C#.NET/source/Yitter.IdGenTest/Program.cs View File

@@ -11,7 +11,7 @@ namespace Yitter.OrgSystem.TestA
class Program
{
// 测试参数(默认配置下,最佳性能是10W/s)
static int genIdCount = 2;//50000; // 计算ID数量(如果要验证50W效率,请将TopOverCostCount设置为20000或适当增加SeqBitLength)
static int genIdCount = 2;//5000; // 计算ID数量(如果要验证50W效率,请将TopOverCostCount设置为20000或适当增加SeqBitLength)
static short method = 1; // 1-漂移算法,2-传统算法


+ 9
- 3
C#.NET/source/Yitter.IdGenerator/YitIdHelper.cs View File

@@ -41,9 +41,15 @@ namespace Yitter.IdGenerator
{
if (_IdGenInstance == null)
{
_IdGenInstance = new DefaultIdGenerator(
new IdGeneratorOptions() { WorkerId = 0 }
);
lock (_IdGenInstance)
{
if (_IdGenInstance == null)
{
_IdGenInstance = new DefaultIdGenerator(
new IdGeneratorOptions() { WorkerId = 0 }
);
}
}
}
return _IdGenInstance.NewLong();


Loading…
Cancel
Save