Skip to content
Snippets Groups Projects
Commit 1a8f547a authored by Jan Tattermusch's avatar Jan Tattermusch
Browse files

use regular lock instead of spinlock

parent 4bdd72be
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment