-
Notifications
You must be signed in to change notification settings - Fork 977
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
Refactor lock
on object
usage to System.Threading.Lock
#11672
Comments
@kirsan31 I saw you commented on the runtime issue. What are your thoughts on this? |
@JeremyKuhne you might be able to shoot this down early. |
One thing I am wondering is if the heavy usage of |
We can explore this when the feature leaves preview state. |
Runtime issue: dotnet/runtime#34812 |
My thots on this:
So if acquire/release without waiting will be faster (it must) then we can feel free to replace object locking in those cases where waiting is rare. In other cases some analysis will be needed I think... |
The code base locks a lot on |
I've raised an roslyn-analyzer rule over at: dotnet/runtime#106907 It would make changes like this easier. |
@lonitra do you know who we can ask about the new Lock type? I am wondering if we can use it based on this comment:
|
Going to do this in .NET 10. I'm comfortable enough with what I've read to commit to this. |
Change internal lock objects to System.Threading.Lock Fixes dotnet#11672
In .NET9 there is the new
System.Threading.Lock
https://learn.microsoft.com/en-us/dotnet/api/system.threading.lock?view=net-9.0
Refactor the
object
used for the lock toLock
where appropriate. The newLock
class when used withlock()
will not usesystem.threading.monitor
, but instead will usesystem.threading.lock
.Benchmarks in this blog post suggest a 25% performance improvement in lock operations:
https://steven-giesel.com/blogPost/4cf6d48a-ec9d-4c68-961c-31fd8d8c1340
There are some limitations, I think the team is best positioned to decide whats best here.
We won't make changes until C# takes the change to the
lock
keyword out of preview.dotnet/csharplang#7104
The text was updated successfully, but these errors were encountered: