Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

启动时休眠时间调整为可配置项 #115

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion C#/source/Yitter.IdGenerator/Contract/IdGeneratorOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ public class IdGeneratorOptions
/// </summary>
public virtual byte TimestampType { get; set; } = 0;


/// <summary>
/// 在使用漂移算法时启动的休眠时间,默认500毫秒
/// </summary>
public virtual TimeSpan SleepTime { get; set; }=TimeSpan.FromMilliseconds(500);

public IdGeneratorOptions()
{

Expand Down
2 changes: 1 addition & 1 deletion C#/source/Yitter.IdGenerator/DefaultIdGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public DefaultIdGenerator(IdGeneratorOptions options)

if (options.Method != 2)
{
Thread.Sleep(500);
Thread.Sleep(options.SleepTime);
}
}

Expand Down