-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allowing actionable options, bug fixes with regards to timeouts, bett…
…er error handling, minor optimizations, improved documentation, added considerably more tests.
- Loading branch information
1 parent
f89c81d
commit edc6f00
Showing
6 changed files
with
215 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.Runtime.CompilerServices; | ||
using System.Threading; | ||
|
||
namespace AsyncKeyedLock | ||
{ | ||
/// <summary> | ||
/// Represents an <see cref="IDisposable"/> for AsyncKeyedLock with timeouts. | ||
/// </summary> | ||
public sealed class AsyncKeyedLockTimeoutReleaser<TKey> : IDisposable | ||
{ | ||
/// <summary> | ||
/// True if the timeout was reached, false if not. | ||
/// </summary> | ||
public bool EnteredSemaphore { get; internal set; } | ||
internal readonly AsyncKeyedLockReleaser<TKey> _releaser; | ||
|
||
internal AsyncKeyedLockTimeoutReleaser(bool enteredSemaphore, AsyncKeyedLockReleaser<TKey> releaser) | ||
{ | ||
EnteredSemaphore = enteredSemaphore; | ||
_releaser = releaser; | ||
} | ||
|
||
/// <summary> | ||
/// Releases the <see cref="SemaphoreSlim"/> object once, depending on whether or not the semaphore was entered. | ||
/// </summary> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public void Dispose() | ||
{ | ||
_releaser.Dispose(EnteredSemaphore); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters