Skip to content

Improve locking performance on .NET 9.0+#1991

Merged
patriksvensson merged 5 commits intospectreconsole:mainfrom
MarkCiliaVincenti:net9locking
Mar 3, 2026
Merged

Improve locking performance on .NET 9.0+#1991
patriksvensson merged 5 commits intospectreconsole:mainfrom
MarkCiliaVincenti:net9locking

Conversation

@MarkCiliaVincenti
Copy link
Copy Markdown
Contributor

@MarkCiliaVincenti MarkCiliaVincenti commented Dec 30, 2025

fixes #1990

  • I have read the Contribution Guidelines
  • I have commented on the issue above and discussed the intended changes
  • A maintainer has signed off on the changes and the issue was assigned to me
  • All newly added code is adequately covered by tests
  • All existing tests are still running without errors
  • The documentation was modified to reflect the changes OR no documentation changes are required.

Changes

Switched from locking on an object to System.Threading.Lock on .NET 9.0 or later, except in cases where we are yielding inside a lock, since this is not supported by System.Threading.Lock.

Makes use of a source generator.


Please upvote 👍 this pull request if you are interested in it.

@phil-scott-78
Copy link
Copy Markdown
Contributor

If I recall, this project has a source generator that would allow this to work without taking on a dependency. I'd be interested in seeing how that looks too.

@MarkCiliaVincenti
Copy link
Copy Markdown
Contributor Author

If I recall, this project has a source generator that would allow this to work without taking on a dependency. I'd be interested in seeing how that looks too.

Happy new year Phil. Indeed it does and this PR sets it up to use it as a source generator rather than taking on the dependency.

@patriksvensson
Copy link
Copy Markdown
Contributor

patriksvensson commented Feb 22, 2026

Sorry for not getting back to you sooner about this PR. The PR needs to be rebased against upstream and have the merge conflicts resolved. I can do this for you, but it will take a couple of days since I'm away on vacation.

@MarkCiliaVincenti
Copy link
Copy Markdown
Contributor Author

Done @patriksvensson

@patriksvensson
Copy link
Copy Markdown
Contributor

@MarkCiliaVincenti Seems to be a merge conflict now 😅

@MarkCiliaVincenti
Copy link
Copy Markdown
Contributor Author

MarkCiliaVincenti commented Mar 1, 2026

@patriksvensson merged, but this is starting to get a bit frustrating so I'm hoping it gets merged in sooner rather than later.

@patriksvensson
Copy link
Copy Markdown
Contributor

That's how things are with open source.

Copy link
Copy Markdown
Contributor

@patriksvensson patriksvensson left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@patriksvensson patriksvensson merged commit 7fabccd into spectreconsole:main Mar 3, 2026
3 checks passed
@patriksvensson
Copy link
Copy Markdown
Contributor

Merged! Thank you for your contribution. Much appreciated! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

System.Threading.Lock

3 participants