diff --git a/C#.NET/source/Yitter.IdGenerator/Core/SnowWorkerM1.cs b/C#.NET/source/Yitter.IdGenerator/Core/SnowWorkerM1.cs index 96b011b..25f75e8 100644 --- a/C#.NET/source/Yitter.IdGenerator/Core/SnowWorkerM1.cs +++ b/C#.NET/source/Yitter.IdGenerator/Core/SnowWorkerM1.cs @@ -66,7 +66,11 @@ namespace Yitter.IdGenerator protected int _GenCountInOneTerm = 0; protected int _TermIndex = 0; + //private static long _StartTimeTick = 0; + //private static long _BaseTimeTick = 0; + public Action GenAction { get; set; } + public SnowWorkerM1(IdGeneratorOptions options) { @@ -104,6 +108,9 @@ namespace Yitter.IdGenerator _TimestampShift = (byte)(WorkerIdBitLength + SeqBitLength); _CurrentSeqNumber = options.MinSeqNumber; + + //_BaseTimeTick = BaseTime.Ticks; + //_StartTimeTick = (long)(DateTime.UtcNow.Subtract(BaseTime).TotalMilliseconds) - Environment.TickCount; } @@ -314,6 +321,8 @@ namespace Yitter.IdGenerator protected virtual long GetCurrentTimeTick() { + //return (long)(DateTime.UtcNow - BaseTime).Ticks; + //return (long)(_StartTimeTick + Environment.TickCount); return (long)(DateTime.UtcNow - BaseTime).TotalMilliseconds; } @@ -332,7 +341,7 @@ namespace Yitter.IdGenerator public virtual long NextId() { - lock (_SyncLock) + lock (_SyncLock) { return _IsOverCost ? NextOverCostId() : NextNormalId(); } diff --git a/Go/source/contract/IdGeneratorOptions.go b/Go/source/contract/IdGeneratorOptions.go index 07bcf65..bd2afc2 100644 --- a/Go/source/contract/IdGeneratorOptions.go +++ b/Go/source/contract/IdGeneratorOptions.go @@ -8,7 +8,7 @@ package contract type IdGeneratorOptions struct { Method uint16 // 雪花计算方法,(1-漂移算法|2-传统算法),默认1 - BaseTime int64 // 基础时间,不能超过当前系统时间 + BaseTime int64 // 基础时间(ms单位),不能超过当前系统时间 WorkerId uint16 // 机器码,与 WorkerIdBitLength 有关系 WorkerIdBitLength byte // 机器码位长,范围:1-21(要求:序列数位长+机器码位长不超过22) SeqBitLength byte // 序列数位长,范围:2-21(要求:序列数位长+机器码位长不超过22) diff --git a/Java/source/src/main/java/com/yitter/contract/IdGeneratorOptions.java b/Java/source/src/main/java/com/yitter/contract/IdGeneratorOptions.java index b6dbf89..2d1dfbb 100644 --- a/Java/source/src/main/java/com/yitter/contract/IdGeneratorOptions.java +++ b/Java/source/src/main/java/com/yitter/contract/IdGeneratorOptions.java @@ -17,7 +17,7 @@ public class IdGeneratorOptions { public short Method = 1; /** - * 基础时间 + * 基础时间(ms单位) * 不能超过当前系统时间 */ public long BaseTime = 1582136402000L; diff --git a/README.md b/README.md index 6c8c035..106ed9a 100644 --- a/README.md +++ b/README.md @@ -187,7 +187,7 @@ Rust:[查看示例][4] QQ群:646049993 -即将推出 C/Rust 等版本。 +即将推出 C 等版本。 [1]: https://gitee.com/yitter/idgenerator/tree/master/C%23.NET diff --git a/Rust/source/src/yitgen/contract/id_generator_options.rs b/Rust/source/src/yitgen/contract/id_generator_options.rs index ee47c11..ab5a634 100644 --- a/Rust/source/src/yitgen/contract/id_generator_options.rs +++ b/Rust/source/src/yitgen/contract/id_generator_options.rs @@ -6,7 +6,7 @@ pub struct IdGeneratorOptions { /// 雪花计算方法,(1-漂移算法|2-传统算法),默认1 pub Method: u8, - /// 基础时间,不能超过当前系统时间 + /// 基础时间(ms单位),不能超过当前系统时间 pub BaseTime: i64, /// 机器码,与 WorkerIdBitLength 有关系 pub WorkerId: u32,