Skip to content

Add info about failure modes to ConcurrentQueue Try methods #11588

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Smaug123
Copy link
Contributor

Summary

The docs are currently silent on the failure modes of most of the System.Collections.Generic.ConcurrentQueue.Try* methods. This PR clarifies what I believe are the semantics: that the Try operations can only fail for the trivial reason that the queue was empty at the time the operation was attempted.

@Smaug123 Smaug123 requested a review from a team as a code owner July 19, 2025 07:15
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jul 19, 2025
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-collections

@@ -551,7 +551,7 @@
<param name="item">The object to add to the <see cref="T:System.Collections.Concurrent.IProducerConsumerCollection`1" />. The value can be a null reference (Nothing in Visual Basic) for reference types.</param>
<summary>Attempts to add an object to the <see cref="T:System.Collections.Concurrent.IProducerConsumerCollection`1" />.</summary>
<returns>
<see langword="true" /> if the object was added successfully; otherwise, <see langword="false" />.</returns>
<see langword="true" /> if the object was added successfully; otherwise, <see langword="false" />. (This operation never returns <see langword="false" /> for <xref:System.Collections.Concurrent.ConcurrentQueue%601>.)</returns>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mentioned in the remarks section below, but that is not the first place I looked for the answer, suggesting that more docs are required.

@Smaug123 Smaug123 force-pushed the failure-modes-of-concurrent branch from 22ab3e8 to 6b8088d Compare July 19, 2025 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Collections community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant