Skip to content

Commit 948e832

Browse files
Nikolay.PianikovNikolay.Pianikov
authored andcommitted
#21 Sometimes flow ids are clashed
1 parent 73d0799 commit 948e832

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

TeamCity.ServiceMessages/Write/Special/Impl/DefaultFlowIdGenerator.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
namespace JetBrains.TeamCity.ServiceMessages.Write.Special.Impl
1818
{
19-
using System;
2019
using System.Globalization;
2120
using System.Threading;
2221

@@ -25,22 +24,14 @@ namespace JetBrains.TeamCity.ServiceMessages.Write.Special.Impl
2524
/// </summary>
2625
public class DefaultFlowIdGenerator : IFlowIdGenerator
2726
{
28-
private int _ids;
27+
private static long ourIds;
2928

3029
/// <summary>
3130
/// Generates new unique FlowId
3231
/// </summary>
3332
public string NewFlowId()
3433
{
35-
return (
36-
#if !NET35 && !NET40
37-
Interlocked.Increment(ref _ids)
38-
#else
39-
Interlocked.Increment(ref _ids) << (27
40-
+ (Thread.CurrentThread.ManagedThreadId << 21)
41-
+ Environment.TickCount % int.MaxValue)
42-
#endif
43-
).ToString(CultureInfo.InvariantCulture);
34+
return Interlocked.Increment(ref ourIds).ToString(CultureInfo.InvariantCulture);
4435
}
4536
}
4637
}

0 commit comments

Comments
 (0)