remove: SafeCriticalSection - remove TryEnter method

This commit is contained in:
Drew Tingen
2021-09-27 12:49:55 -04:00
committed by Chris Cameron
parent 84b5b636f6
commit 033008616f
3 changed files with 1 additions and 62 deletions

View File

@@ -37,30 +37,5 @@ namespace ICD.Common.Utils.Tests
Assert.Inconclusive();
}
[Test]
public void TryEnterTest()
{
int result = 0;
SafeCriticalSection section = new SafeCriticalSection();
section.Enter();
// ReSharper disable once NotAccessedVariable
ThreadingUtils.SafeInvoke(() => { result = section.TryEnter() ? 0 : 1; });
Assert.IsTrue(ThreadingUtils.Wait(() => result == 1, 1000));
section.Leave();
// ReSharper disable once RedundantAssignment
ThreadingUtils.SafeInvoke(() =>
{
result = section.TryEnter() ? 2 : 0;
section.Leave();
});
Assert.IsTrue(ThreadingUtils.Wait(() => result == 2, 1000));
}
}
}
}

View File

@@ -90,31 +90,6 @@ namespace ICD.Common.Utils
}
}
/// <summary>
/// Attempt to enter the critical section without blocking.
/// </summary>
/// <returns>
/// True, calling thread has ownership of the critical section; otherwise, false.
/// </returns>
public bool TryEnter()
{
if (m_CriticalSection == null)
return false;
try
{
#if DEBUG
return m_CriticalSection.WaitForMutex(0);
#else
return m_CriticalSection.TryEnter();
#endif
}
catch (ObjectDisposedException)
{
return false;
}
}
#endregion
}
}

View File

@@ -24,17 +24,6 @@ namespace ICD.Common.Utils
Monitor.Exit(this);
}
/// <summary>
/// Attempt to enter the critical section without blocking.
/// </summary>
/// <returns>
/// True, calling thread has ownership of the critical section; otherwise, false.
/// </returns>
public bool TryEnter()
{
return Monitor.TryEnter(this);
}
#endregion
}
}