-
Notifications
You must be signed in to change notification settings - Fork 153
Description
Is your feature request related to a problem? Please describe.
SemaphoreSlim and AsyncSemaphore have been banned via analyzers with the replacement preference being ReentrantSemaphore due to it being JTF aware.
AsyncSemaphore's EnterAsync implementation allows for a timeout parameter
ReentrantSemaphore's ExecuteAsync implementation always enters the underlying AsyncSemphare with an infinite timeout
Describe the solution you'd like
AsyncSemaphore supports an EnterAsync timeout. I would like to see ReentrantSemaphore allow for this parameter to be passed as an argument during ExecuteAsync.
Describe alternatives you've considered
Unless I am mistaken,
You can partially work around this by passing a cancellation token that times out, but this timeout is not specific to acquiring the lock. If the critical section is a long running operation, it is possible that a passed in cancellation token would cancel even though entrance into the critical section was achieved.