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

Include in WaitingWriteCount the thread that may be waiting in upgradable mode #113982

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

Conversation

eduardo-vp
Copy link
Member

@eduardo-vp eduardo-vp commented Mar 27, 2025

Fixes #107077.

@Copilot Copilot bot review requested due to automatic review settings March 27, 2025 18:54
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the WaitingWriteCount property in ReaderWriterLockSlim so that it includes the thread potentially waiting in upgradable mode, addressing issue #107077.

  • Added a comment explaining the inclusion of upgradable mode waiters.
  • Adjusted the WaitingWriteCount property to sum _numWriteWaiters and _numWriteUpgradeWaiters.
Comments suppressed due to low confidence (1)

src/libraries/System.Private.CoreLib/src/System/Threading/ReaderWriterLockSlim.cs:1416

  • Verify that _numWriteWaiters and _numWriteUpgradeWaiters are updated under the same concurrency control mechanism to prevent potential race conditions when summing their values.
public int WaitingWriteCount => (int)_numWriteWaiters + (int)_numWriteUpgradeWaiters;

@eduardo-vp eduardo-vp force-pushed the fix-ReaderWriterLockSlim-WaitingWriteCount branch from bc7881b to 4457707 Compare March 28, 2025 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants