Skip to content

Commit e10c20e

Browse files
committed
Replace usage of SpinWait struct with simple increment operation. SpinWait.SpinOnce() takes too much time than the original Thread.SpinWait(5).
1 parent 99ad4d1 commit e10c20e

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

BasicTest/Program.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ static void MassiveBulkOpsAsync(int AsyncOpsQty, bool preserveOrder, bool withCo
3535
var conn = muxer.GetDatabase();
3636
muxer.Wait(conn.PingAsync());
3737

38+
int number = 0;
3839
Action<Task> nonTrivial = delegate
3940
{
4041
#if !DNXCORE50
4142
Thread.SpinWait(5);
4243
#else
43-
var spinWait = new SpinWait();
44-
for (int i = 0; i < 5; i++)
44+
for (int i = 0; i < 50; i++)
4545
{
46-
spinWait.SpinOnce();
46+
number++;
4747
}
4848
#endif
4949
};

StackExchange.Redis.Tests/BasicOps.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,15 @@ public void MassiveBulkOpsAsync(bool preserveOrder, bool withContinuation)
234234
var conn = muxer.GetDatabase();
235235
muxer.Wait(conn.PingAsync());
236236

237+
int number = 0;
237238
Action<Task> nonTrivial = delegate
238239
{
239240
#if !DNXCORE50
240241
Thread.SpinWait(5);
241242
#else
242-
var spinWait = new SpinWait();
243-
for (int i = 0; i < 5; i++)
243+
for (int i = 0; i < 50; i++)
244244
{
245-
spinWait.SpinOnce();
245+
number++;
246246
}
247247
#endif
248248
};

0 commit comments

Comments
 (0)