Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConcurrentQueueSegment allows spinning threads to sleep. #44265

Merged
merged 4 commits into from
Nov 5, 2020
Merged
Changes from 1 commit
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
Prev Previous commit
Apply suggestions from code review
Co-authored-by: Stephen Toub <stoub@microsoft.com>
  • Loading branch information
alexcovington and stephentoub authored Nov 5, 2020
commit 729d6468e97eeecdf752290ed47ac85f518cbdc1
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ internal sealed class ConcurrentQueueSegment<T>
#pragma warning restore 0649

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

/// <summary>Creates the segment.</summary>
/// <param name="boundedLength">
@@ -247,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: _sleep1Threshold);
spinner.SpinOnce(Sleep1Threshold);
}
}

@@ -304,7 +304,7 @@ public bool TryEnqueue(T item)
}

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