diff --git a/C#.NET/source/Yitter.IdGenTest/Program.cs b/C#.NET/source/Yitter.IdGenTest/Program.cs
index e436435..5ff3296 100644
--- a/C#.NET/source/Yitter.IdGenTest/Program.cs
+++ b/C#.NET/source/Yitter.IdGenTest/Program.cs
@@ -140,7 +140,7 @@ namespace Yitter.OrgSystem.TestA
WorkerId = 1,
WorkerIdBitLength = 6,
- SeqBitLength = 6,
+ SeqBitLength = 12,
//TopOverCostCount = 2000,
//DataCenterIdBitLength = 0,
@@ -153,7 +153,7 @@ namespace Yitter.OrgSystem.TestA
//IdGen = new DefaultIdGenerator(options);
YitIdHelper.SetIdGenerator(options);
- genIdCount = 50000;
+ genIdCount = 5000000;
while (true)
{
DateTime start = DateTime.Now;
@@ -186,21 +186,21 @@ namespace Yitter.OrgSystem.TestA
if (outputLog)
{
- IdGen.GenIdActionAsync = (arg =>
- {
- if (arg.ActionType == 1)
- {
- Console.WriteLine($">>>> {arg.WorkerId}:开始:{DateTime.Now.ToString("mm:ss:fff")}, 周期次序:{arg.TermIndex}");
- }
- else if (arg.ActionType == 2)
- {
- Console.WriteLine($"<<<< {arg.WorkerId}:结束:{DateTime.Now.ToString("mm:ss:fff")},漂移 {arg.OverCostCountInOneTerm} 次,产生 {arg.GenCountInOneTerm} 个, 周期次序:{arg.TermIndex}");
- }
- if (arg.ActionType == 8)
- {
- Console.WriteLine($"---- {arg.WorkerId}:AA结束:{DateTime.Now.ToString("mm:ss:fff")},时间回拨");
- }
- });
+ //IdGen.GenIdActionAsync = (arg =>
+ //{
+ // if (arg.ActionType == 1)
+ // {
+ // Console.WriteLine($">>>> {arg.WorkerId}:开始:{DateTime.Now.ToString("mm:ss:fff")}, 周期次序:{arg.TermIndex}");
+ // }
+ // else if (arg.ActionType == 2)
+ // {
+ // Console.WriteLine($"<<<< {arg.WorkerId}:结束:{DateTime.Now.ToString("mm:ss:fff")},漂移 {arg.OverCostCountInOneTerm} 次,产生 {arg.GenCountInOneTerm} 个, 周期次序:{arg.TermIndex}");
+ // }
+ // if (arg.ActionType == 8)
+ // {
+ // Console.WriteLine($"---- {arg.WorkerId}:AA结束:{DateTime.Now.ToString("mm:ss:fff")},时间回拨");
+ // }
+ //});
}
for (int i = 1; i < workerCount + 1; i++)
@@ -233,10 +233,10 @@ namespace Yitter.OrgSystem.TestA
if (outputLog)
{
- idGen2.GenIdActionAsync = (arg =>
- {
- Console.WriteLine($"{DateTime.Now.ToString("mm:ss:fff")} {arg.WorkerId} 漂移了 {arg.OverCostCountInOneTerm}, 顺序:{arg.TermIndex}");
- });
+ //idGen2.GenIdActionAsync = (arg =>
+ //{
+ // Console.WriteLine($"{DateTime.Now.ToString("mm:ss:fff")} {arg.WorkerId} 漂移了 {arg.OverCostCountInOneTerm}, 顺序:{arg.TermIndex}");
+ //});
}
testList.Add(test);
diff --git a/C#.NET/source/Yitter.IdGenerator/Contract/IIdGenerator.cs b/C#.NET/source/Yitter.IdGenerator/Contract/IIdGenerator.cs
index d19dc47..275b3ed 100644
--- a/C#.NET/source/Yitter.IdGenerator/Contract/IIdGenerator.cs
+++ b/C#.NET/source/Yitter.IdGenerator/Contract/IIdGenerator.cs
@@ -16,7 +16,7 @@ namespace Yitter.IdGenerator
///
/// 生成过程中产生的事件
///
- Action GenIdActionAsync { get; set; }
+ //Action GenIdActionAsync { get; set; }
///
/// 生成新的long型Id
diff --git a/C#.NET/source/Yitter.IdGenerator/Contract/ISnowWorker.cs b/C#.NET/source/Yitter.IdGenerator/Contract/ISnowWorker.cs
index 3194c2b..93d1b19 100644
--- a/C#.NET/source/Yitter.IdGenerator/Contract/ISnowWorker.cs
+++ b/C#.NET/source/Yitter.IdGenerator/Contract/ISnowWorker.cs
@@ -15,7 +15,7 @@ namespace Yitter.IdGenerator
{
internal interface ISnowWorker
{
- Action GenAction { get; set; }
+ //Action GenAction { get; set; }
long NextId();
}
diff --git a/C#.NET/source/Yitter.IdGenerator/Core/SnowWorkerM1.cs b/C#.NET/source/Yitter.IdGenerator/Core/SnowWorkerM1.cs
index f1a0230..47e9fa5 100644
--- a/C#.NET/source/Yitter.IdGenerator/Core/SnowWorkerM1.cs
+++ b/C#.NET/source/Yitter.IdGenerator/Core/SnowWorkerM1.cs
@@ -327,7 +327,7 @@ namespace Yitter.IdGenerator
return CalcId(_LastTimeTick);
}
- protected virtual long CalcId(in long useTimeTick)
+ protected virtual long CalcId(long useTimeTick)
{
var result = ((useTimeTick << _TimestampShift) +
((long)WorkerId << SeqBitLength) +
@@ -337,7 +337,7 @@ namespace Yitter.IdGenerator
return result;
}
- protected virtual long CalcTurnBackId(in long useTimeTick)
+ protected virtual long CalcTurnBackId(long useTimeTick)
{
var result = ((useTimeTick << _TimestampShift) +
((long)WorkerId << SeqBitLength) + _TurnBackIndex);
diff --git a/C#.NET/source/Yitter.IdGenerator/Core/SnowWorkerM3.cs b/C#.NET/source/Yitter.IdGenerator/Core/SnowWorkerM3.cs
index 6bab285..4ad78a7 100644
--- a/C#.NET/source/Yitter.IdGenerator/Core/SnowWorkerM3.cs
+++ b/C#.NET/source/Yitter.IdGenerator/Core/SnowWorkerM3.cs
@@ -50,7 +50,7 @@ namespace Yitter.IdGenerator
_TimestampShift = (byte)(DataCenterIdBitLength + WorkerIdBitLength + SeqBitLength);
}
- protected override long CalcId(in long useTimeTick)
+ protected override long CalcId(long useTimeTick)
{
var result = ((useTimeTick << _TimestampShift) +
((long)DataCenterId << DataCenterIdBitLength) +
@@ -61,7 +61,7 @@ namespace Yitter.IdGenerator
return result;
}
- protected override long CalcTurnBackId(in long useTimeTick)
+ protected override long CalcTurnBackId(long useTimeTick)
{
var result = ((useTimeTick << _TimestampShift) +
((long)DataCenterId << DataCenterIdBitLength) +
diff --git a/C#.NET/source/Yitter.IdGenerator/DefaultIdGenerator.cs b/C#.NET/source/Yitter.IdGenerator/DefaultIdGenerator.cs
index f21ad03..84c7cf6 100644
--- a/C#.NET/source/Yitter.IdGenerator/DefaultIdGenerator.cs
+++ b/C#.NET/source/Yitter.IdGenerator/DefaultIdGenerator.cs
@@ -21,35 +21,35 @@ namespace Yitter.IdGenerator
{
private ISnowWorker _SnowWorker { get; set; }
- public Action GenIdActionAsync
- {
- get => _SnowWorker.GenAction;
- set => _SnowWorker.GenAction = value;
- }
+ //public Action GenIdActionAsync
+ //{
+ // get => _SnowWorker.GenAction;
+ // set => _SnowWorker.GenAction = value;
+ //}
public DefaultIdGenerator(IdGeneratorOptions options)
{
if (options == null)
{
- throw new ApplicationException("options error.");
+ throw new ArgumentException("options error.");
}
// 1.BaseTime
if (options.BaseTime < DateTime.Now.AddYears(-50) || options.BaseTime > DateTime.Now)
{
- throw new ApplicationException("BaseTime error.");
+ throw new ArgumentException("BaseTime error.");
}
// 2.WorkerIdBitLength
int maxLength = options.TimestampType == 0 ? 22 : 31; // (秒级时间戳时放大到31位)
if (options.WorkerIdBitLength <= 0)
{
- throw new ApplicationException("WorkerIdBitLength error.(range:[1, 21])");
+ throw new ArgumentException("WorkerIdBitLength error.(range:[1, 21])");
}
if (options.DataCenterIdBitLength + options.WorkerIdBitLength + options.SeqBitLength > maxLength)
{
- throw new ApplicationException("error:DataCenterIdBitLength + WorkerIdBitLength + SeqBitLength <= " + maxLength);
+ throw new ArgumentException("error:DataCenterIdBitLength + WorkerIdBitLength + SeqBitLength <= " + maxLength);
}
// 3.WorkerId & DataCenterId
@@ -60,19 +60,19 @@ namespace Yitter.IdGenerator
}
if (options.WorkerId < 0 || options.WorkerId > maxWorkerIdNumber)
{
- throw new ApplicationException("WorkerId error. (range:[0, " + maxWorkerIdNumber + "]");
+ throw new ArgumentException("WorkerId error. (range:[0, " + maxWorkerIdNumber + "]");
}
var maxDataCenterIdNumber = (1 << options.DataCenterIdBitLength) - 1;
if (options.DataCenterId < 0 || options.DataCenterId > maxDataCenterIdNumber)
{
- throw new ApplicationException("DataCenterId error. (range:[0, " + maxDataCenterIdNumber + "]");
+ throw new ArgumentException("DataCenterId error. (range:[0, " + maxDataCenterIdNumber + "]");
}
// 4.SeqBitLength
if (options.SeqBitLength < 2 || options.SeqBitLength > 21)
{
- throw new ApplicationException("SeqBitLength error. (range:[2, 21])");
+ throw new ArgumentException("SeqBitLength error. (range:[2, 21])");
}
// 5.MaxSeqNumber
@@ -83,19 +83,19 @@ namespace Yitter.IdGenerator
}
if (options.MaxSeqNumber < 0 || options.MaxSeqNumber > maxSeqNumber)
{
- throw new ApplicationException("MaxSeqNumber error. (range:[1, " + maxSeqNumber + "]");
+ throw new ArgumentException("MaxSeqNumber error. (range:[1, " + maxSeqNumber + "]");
}
// 6.MinSeqNumber
if (options.MinSeqNumber < 5 || options.MinSeqNumber > maxSeqNumber)
{
- throw new ApplicationException("MinSeqNumber error. (range:[5, " + maxSeqNumber + "]");
+ throw new ArgumentException("MinSeqNumber error. (range:[5, " + maxSeqNumber + "]");
}
// 7.TopOverCostCount
if (options.TopOverCostCount < 0 || options.TopOverCostCount > 10000)
{
- throw new ApplicationException("TopOverCostCount error. (range:[0, 10000]");
+ throw new ArgumentException("TopOverCostCount error. (range:[0, 10000]");
}
switch (options.Method)
diff --git a/C#.NET/source/Yitter.IdGenerator/YitIdHelper.cs b/C#.NET/source/Yitter.IdGenerator/YitIdHelper.cs
index cb48892..8e37d19 100644
--- a/C#.NET/source/Yitter.IdGenerator/YitIdHelper.cs
+++ b/C#.NET/source/Yitter.IdGenerator/YitIdHelper.cs
@@ -51,7 +51,7 @@ namespace Yitter.IdGenerator
// }
//}
- if (_IdGenInstance == null) throw new ApplicationException("Please initialize Yitter.IdGeneratorOptions first.");
+ if (_IdGenInstance == null) throw new ArgumentException("Please initialize Yitter.IdGeneratorOptions first.");
return _IdGenInstance.NewLong();
}