1
0
mirror of synced 2026-04-18 06:18:40 +08:00

!6 D语言移植

* Porting to D
* The pthread needed.
This commit is contained in:
BitWorld
2021-04-08 21:04:43 +08:00
committed by yitter
parent b3a77a2824
commit a82d9cb063
18 changed files with 768 additions and 3 deletions

View File

@@ -0,0 +1,72 @@
/*
* 版权属于yitter(yitter@126.com)
* 开源地址https://gitee.com/yitter/idgenerator
*/
module yitter.contract.IdGeneratorOptions;
import std.datetime;
/**
* 雪花算法使用的参数
* 参数说明参考 README.md 配置参数 章节
*/
class IdGeneratorOptions {
/**
* 雪花计算方法
* 1-漂移算法|2-传统算法默认1
*/
short Method = 1;
/**
* 基础时间ms单位
* 不能超过当前系统时间
*/
// long BaseTime = 1582136402000L;
SysTime BaseTime;
/**
* 机器码
* 必须由外部设定最大值 2^WorkerIdBitLength-1
*/
short WorkerId = 0;
/**
* 机器码位长
* 默认值6取值范围 [1, 15]要求序列数位长+机器码位长不超过22
*/
byte WorkerIdBitLength = 6;
/**
* 序列数位长
* 默认值6取值范围 [3, 21]要求序列数位长+机器码位长不超过22
*/
byte SeqBitLength = 6;
/**
* 最大序列数
* 设置范围 [MinSeqNumber, 2^SeqBitLength-1]默认值0表示最大序列数取最大值2^SeqBitLength-1]
*/
short MaxSeqNumber = 0;
/**
* 最小序列数
* 默认值5取值范围 [5, MaxSeqNumber]每毫秒的前5个序列数对应编号是0-4是保留位其中1-4是时间回拨相应预留位0是手工新值预留位
*/
short MinSeqNumber = 5;
/**
* 最大漂移次数
* 默认2000推荐范围500-10000与计算能力有关
*/
short TopOverCostCount = 2000;
this() {
BaseTime = SysTime(DateTime(2020, 2, 20, 2, 20, 2));
}
this(short workerId) {
WorkerId = workerId;
BaseTime = SysTime(DateTime(2020, 2, 20, 2, 20, 2));
}
}