working on dynamic wrapping
This commit is contained in:
@@ -105,7 +105,7 @@ namespace StgSharp.Collections
|
||||
public T[] PopRange(int count)
|
||||
{
|
||||
if (count <= 0) {
|
||||
return Array.Empty<T>();
|
||||
return [];
|
||||
}
|
||||
|
||||
T[] result = new T[count];
|
||||
@@ -122,7 +122,7 @@ namespace StgSharp.Collections
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
return Array.Empty<T>();
|
||||
return [];
|
||||
}
|
||||
|
||||
T[] trimmed = new T[i];
|
||||
@@ -251,7 +251,7 @@ namespace StgSharp.Collections
|
||||
if (Volatile.Read(ref _states[newTop]) == 0)
|
||||
{
|
||||
// attempt to restore top; ok if it fails due to concurrent operations
|
||||
Interlocked.CompareExchange(ref _top, newTop + 1, newTop);
|
||||
_ = Interlocked.CompareExchange(ref _top, newTop + 1, newTop);
|
||||
sw.SpinOnce();
|
||||
continue;
|
||||
}
|
||||
@@ -259,7 +259,7 @@ namespace StgSharp.Collections
|
||||
value = _values[newTop];
|
||||
_values[newTop] = default!; // avoid ref retention
|
||||
Volatile.Write(ref _states[newTop], 0); // mark empty
|
||||
Interlocked.Decrement(ref _count);
|
||||
_ = Interlocked.Decrement(ref _count);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user