-
Notifications
You must be signed in to change notification settings - Fork 248
Expand file tree
/
Copy pathDistributedUpgradeableReaderWriterLockProviderExtensions.cs
More file actions
50 lines (39 loc) · 3.39 KB
/
Copy pathDistributedUpgradeableReaderWriterLockProviderExtensions.cs
File metadata and controls
50 lines (39 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// AUTO-GENERATED
using Medallion.Threading.Internal;
namespace Medallion.Threading;
/// <summary>
/// Productivity helper methods for <see cref="IDistributedUpgradeableReaderWriterLockProvider" />
/// </summary>
public static class DistributedUpgradeableReaderWriterLockProviderExtensions
{
# region Single Lock Methods
/// <summary>
/// Equivalent to calling <see cref="IDistributedUpgradeableReaderWriterLockProvider.CreateUpgradeableReaderWriterLock(string)" /> and then
/// <see cref="IDistributedUpgradeableReaderWriterLock.TryAcquireUpgradeableReadLock(TimeSpan, CancellationToken)" />.
/// </summary>
public static IDistributedLockUpgradeableHandle? TryAcquireUpgradeableReadLock(this IDistributedUpgradeableReaderWriterLockProvider provider, string name, TimeSpan timeout = default, CancellationToken cancellationToken = default) =>
(provider ?? throw new ArgumentNullException(nameof(provider))).CreateUpgradeableReaderWriterLock(name).TryAcquireUpgradeableReadLock(timeout, cancellationToken);
/// <summary>
/// Equivalent to calling <see cref="IDistributedUpgradeableReaderWriterLockProvider.CreateUpgradeableReaderWriterLock(string)" /> and then
/// <see cref="IDistributedUpgradeableReaderWriterLock.AcquireUpgradeableReadLock(TimeSpan?, CancellationToken)" />.
/// </summary>
public static IDistributedLockUpgradeableHandle AcquireUpgradeableReadLock(this IDistributedUpgradeableReaderWriterLockProvider provider, string name, TimeSpan? timeout = null, CancellationToken cancellationToken = default) =>
(provider ?? throw new ArgumentNullException(nameof(provider))).CreateUpgradeableReaderWriterLock(name).AcquireUpgradeableReadLock(timeout, cancellationToken);
/// <summary>
/// Equivalent to calling <see cref="IDistributedUpgradeableReaderWriterLockProvider.CreateUpgradeableReaderWriterLock(string)" /> and then
/// <see cref="IDistributedUpgradeableReaderWriterLock.TryAcquireUpgradeableReadLockAsync(TimeSpan, CancellationToken)" />.
/// </summary>
public static ValueTask<IDistributedLockUpgradeableHandle?> TryAcquireUpgradeableReadLockAsync(this IDistributedUpgradeableReaderWriterLockProvider provider, string name, TimeSpan timeout = default, CancellationToken cancellationToken = default) =>
(provider ?? throw new ArgumentNullException(nameof(provider))).CreateUpgradeableReaderWriterLock(name).TryAcquireUpgradeableReadLockAsync(timeout, cancellationToken);
/// <summary>
/// Equivalent to calling <see cref="IDistributedUpgradeableReaderWriterLockProvider.CreateUpgradeableReaderWriterLock(string)" /> and then
/// <see cref="IDistributedUpgradeableReaderWriterLock.AcquireUpgradeableReadLockAsync(TimeSpan?, CancellationToken)" />.
/// </summary>
public static ValueTask<IDistributedLockUpgradeableHandle> AcquireUpgradeableReadLockAsync(this IDistributedUpgradeableReaderWriterLockProvider provider, string name, TimeSpan? timeout = null, CancellationToken cancellationToken = default) =>
(provider ?? throw new ArgumentNullException(nameof(provider))).CreateUpgradeableReaderWriterLock(name).AcquireUpgradeableReadLockAsync(timeout, cancellationToken);
# endregion
# region Composite Lock Methods
// Composite methods are not supported for IDistributedUpgradeableReaderWriterLock
// because a composite acquire operation must be able to roll back and upgrade does not support that.
# endregion
}