1
0
mirror of synced 2026-04-27 02:38:39 +08:00

auto commit

This commit is contained in:
zhouzj
2021-03-22 14:28:26 +08:00
parent d60154b946
commit 3aa9f6f42b
8 changed files with 295 additions and 13 deletions

View File

@@ -15,7 +15,7 @@ namespace Yitter.OrgSystem.TestA
static bool single = true;
static bool outputLog = true;
static bool outputLog = false;
static IIdGenerator IdGen = null;
static IList<GenTest> testList = new List<GenTest>();
static bool checkResult = false;
@@ -38,7 +38,7 @@ namespace Yitter.OrgSystem.TestA
// MaxSeqNumber = 200,
BaseTime = DateTime.Now.AddYears(-10),
// BaseTime = DateTime.Now.AddYears(-10),
};
IIdGenerator IdGen = new DefaultIdGenerator(options);
@@ -54,7 +54,7 @@ namespace Yitter.OrgSystem.TestA
{
Go(options);
Thread.Sleep(1000); // 每隔3秒执行一次Go
Console.WriteLine("Hello World!");
Console.WriteLine("Hello World! C#");
}
}

View File

@@ -117,6 +117,8 @@ namespace Yitter.IdGenerator
private void BeginOverCostAction(in long useTimeTick)
{
return;
if (GenAction == null)
{
return;
@@ -137,6 +139,7 @@ namespace Yitter.IdGenerator
{
_TermIndex = 0;
}
return;
if (GenAction == null)
{
@@ -154,6 +157,8 @@ namespace Yitter.IdGenerator
private void BeginTurnBackAction(in long useTimeTick)
{
return;
if (GenAction == null)
{
return;
@@ -170,6 +175,8 @@ namespace Yitter.IdGenerator
private void EndTurnBackAction(in long useTimeTick)
{
return;
if (GenAction == null)
{
return;

View File

@@ -45,10 +45,15 @@ namespace Yitter.IdGenerator
throw new ApplicationException("errorWorkerIdBitLength + SeqBitLength <= 22");
}
if (options.WorkerIdBitLength <= 0)
{
throw new ApplicationException("WorkerIdBitLength error.(range:[1, 21])");
}
var maxWorkerIdNumber = Math.Pow(2, options.WorkerIdBitLength) - 1;
if (options.WorkerId < 0 || options.WorkerId > maxWorkerIdNumber)
{
throw new ApplicationException("WorkerId error. (range:[1, " + maxWorkerIdNumber + "]");
throw new ApplicationException("WorkerId error. (range:[0, " + (maxWorkerIdNumber > 0 ? maxWorkerIdNumber : 63) + "]");
}
if (options.SeqBitLength < 2 || options.SeqBitLength > 21)