Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ internal sealed class ConcurrentQueueSegment<T>
internal ConcurrentQueueSegment<T>? _nextSegment; // SOS's ThreadPool command depends on this name
#pragma warning restore 0649

/// <summary>Threshold to spin before allowing threads to sleep when there is contention.</summary>
private const int Sleep1Threshold = 8;

/// <summary>Creates the segment.</summary>
/// <param name="boundedLength">
/// The maximum number of elements the segment can contain. Must be a power of 2.
Expand Down Expand Up @@ -183,7 +186,7 @@ public bool TryDequeue([MaybeNullWhen(false)] out T item)
}

// Lost a race. Spin a bit, then try again.
spinner.SpinOnce(sleep1Threshold: -1);
spinner.SpinOnce(Sleep1Threshold);
}
}

Expand Down Expand Up @@ -244,7 +247,7 @@ public bool TryPeek([MaybeNullWhen(false)] out T result, bool resultUsed)
}

// Lost a race. Spin a bit, then try again.
spinner.SpinOnce(sleep1Threshold: -1);
spinner.SpinOnce(Sleep1Threshold);
}
}

Expand Down Expand Up @@ -301,7 +304,7 @@ public bool TryEnqueue(T item)
}

// Lost a race. Spin a bit, then try again.
spinner.SpinOnce(sleep1Threshold: -1);
spinner.SpinOnce(Sleep1Threshold);
}
}

Expand Down