Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/StackExchange.Redis/AwaitableMutex.net.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
using System.Threading;
using System.Threading.Tasks;

// #if NET
#if NET
namespace StackExchange.Redis;

internal partial struct AwaitableMutex
{
private readonly int _timeoutMilliseconds;

// note: this does not guarantee "fairness", but that's OK for our use-case - we mostly just want
// a sync+async awaitable mutex, which this does; the .NET Framework version has a hand-written
// implementation (see .netfx.cx for reasons), which *is* fair, but we'd rather not pay that overhead
// here. Good-enough-is.
private readonly SemaphoreSlim _mutex;

private partial AwaitableMutex(int timeoutMilliseconds)
Expand All @@ -28,4 +33,4 @@ public partial ValueTask<bool> TryTakeAsync(CancellationToken cancellationToken)

public partial void Release() => _mutex.Release();
}
// #endif
#endif
Loading
Loading