diff options
author | Jan Tattermusch <jtattermusch@google.com> | 2015-11-18 13:09:20 -0800 |
---|---|---|
committer | Jan Tattermusch <jtattermusch@google.com> | 2015-11-18 13:09:20 -0800 |
commit | 1a8f547a0b06323ce1efaf67df46044e13a790ef (patch) | |
tree | 66cb82bcc2fadd31d3583a76e7d4c670fb9cb40a /src/csharp | |
parent | 4bdd72befe2c32b8cef04cf440284641bfb5de3a (diff) |
use regular lock instead of spinlock
Diffstat (limited to 'src/csharp')
-rw-r--r-- | src/csharp/Grpc.IntegrationTesting/Histogram.cs | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/src/csharp/Grpc.IntegrationTesting/Histogram.cs b/src/csharp/Grpc.IntegrationTesting/Histogram.cs index 0a294dde02..7e7cb2c4de 100644 --- a/src/csharp/Grpc.IntegrationTesting/Histogram.cs +++ b/src/csharp/Grpc.IntegrationTesting/Histogram.cs @@ -52,8 +52,7 @@ namespace Grpc.IntegrationTesting /// </summary> public class Histogram { - readonly SpinLock spinlock = new SpinLock(); - + readonly object myLock = new object(); readonly double multiplier; readonly double oneOnLogMultiplier; readonly double maxPossible; @@ -79,16 +78,10 @@ namespace Grpc.IntegrationTesting public void AddObservation(double value) { - bool lockTaken = false; - spinlock.Enter(ref lockTaken); - try + lock (myLock) { AddObservationUnsafe(value); } - finally - { - if (lockTaken) spinlock.Exit(); - } } @@ -97,16 +90,10 @@ namespace Grpc.IntegrationTesting /// </summary> public HistogramData GetSnapshot(bool reset = false) { - bool lockTaken = false; - spinlock.Enter(ref lockTaken); - try + lock (myLock) { return GetSnapshotUnsafe(reset); } - finally - { - if (lockTaken) spinlock.Exit(); - } } /// <summary> |