RecyclableLongList.IndexOf stability & performance improvements.
This commit is contained in:
1 parent
e3ca5b4f87
commit
fb689e84d6
4 files changed
+298
-81
No files matched your search
@@ -0,0 +1,26 @@
|
||||
namespace Recyclable.Collections.Parallel
|
||||
{
|
||||
public struct SpinLockSlimmer
|
||||
{
|
||||
private volatile int _locked;
|
||||
|
||||
public void Enter()
|
||||
{
|
||||
if (Interlocked.CompareExchange(ref _locked, 1, 0) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SpinWait waiter = new();
|
||||
while (Interlocked.CompareExchange(ref _locked, 1, 0) == 1)
|
||||
{
|
||||
waiter.SpinOnce();
|
||||
}
|
||||
}
|
||||
|
||||
public void Exit()
|
||||
{
|
||||
_locked = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user