Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

eduardo-vp
Copy link
Member

No description provided.

Copy link
Contributor

Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.

@eduardo-vp eduardo-vp requested a review from kouvel June 5, 2024 18:31
@eduardo-vp eduardo-vp marked this pull request as ready for review June 5, 2024 20:25
@eduardo-vp
Copy link
Member Author

CI errors are known

@eduardo-vp eduardo-vp merged commit e2f0476 into dotnet:main Jun 5, 2024
@EgorBo
Copy link
Member

EgorBo commented Jun 5, 2024

@kouvel I am just wondering - does F# have a special treatment for Lock too?

Also, should Monitor.TryEnter throw an error if Lock object is passed? so other CIL languages could realize they need a special treatment here

cc @vzarytovskii

@vzarytovskii
Copy link
Member

lock in F# is just a function, which takes a lock object and a function. No special treatment.

@EgorBo
Copy link
Member

EgorBo commented Jun 5, 2024

lock in F# is just a function, which takes a lock object and a function. No special treatment.

From my understanding, the problem is - we now have this Lock type and it shouldn't be used (behind the scene) with Monitor type, otherwise if user defines a Lock lock object and then mixes its usage with lock keyword or f# function (doesn't matter) with explicit TryEnter/Scope APIs they might run into terrible hard-to-repro bugs

@kouvel
Copy link
Contributor

kouvel commented Jun 6, 2024

Yea that's a good point. I'm not sure if there's a way to disallow Lock-typed objects to be used statically with the lock function. At least that would be a deterrent but the Lock type could also be easily casted away. Not sure if there is a good solution to that, thoughts?

@kouvel
Copy link
Contributor

kouvel commented Jun 6, 2024

A run-time check adds a bit of measurable cost to locking, and if done in the lock function may also increase code size because it seems to be inlined. Or maybe there should be some guidance such as not to use Lock with lock in F#?

@github-actions github-actions bot locked and limited conversation to collaborators Jul 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants