1+ using Medallion . Threading . Internal ;
2+
3+ namespace Medallion . Threading . Etcd ;
4+
5+ public partial class EtcdLeaseDistributedLock
6+ {
7+ // AUTO-GENERATED
8+
9+ IDistributedSynchronizationHandle ? IDistributedLock . TryAcquire ( TimeSpan timeout , CancellationToken cancellationToken ) =>
10+ this . TryAcquire ( timeout , cancellationToken ) ;
11+ IDistributedSynchronizationHandle IDistributedLock . Acquire ( TimeSpan ? timeout , CancellationToken cancellationToken ) =>
12+ this . Acquire ( timeout , cancellationToken ) ;
13+ ValueTask < IDistributedSynchronizationHandle ? > IDistributedLock . TryAcquireAsync ( TimeSpan timeout , CancellationToken cancellationToken ) =>
14+ this . TryAcquireAsync ( timeout , cancellationToken ) . Convert ( To < IDistributedSynchronizationHandle ? > . ValueTask ) ;
15+ ValueTask < IDistributedSynchronizationHandle > IDistributedLock . AcquireAsync ( TimeSpan ? timeout , CancellationToken cancellationToken ) =>
16+ this . AcquireAsync ( timeout , cancellationToken ) . Convert ( To < IDistributedSynchronizationHandle > . ValueTask ) ;
17+
18+ /// <summary>
19+ /// Attempts to acquire the lock synchronously. Usage:
20+ /// <code>
21+ /// using (var handle = myLock.TryAcquire(...))
22+ /// {
23+ /// if (handle != null) { /* we have the lock! */ }
24+ /// }
25+ /// // dispose releases the lock if we took it
26+ /// </code>
27+ /// </summary>
28+ /// <param name="timeout">How long to wait before giving up on the acquisition attempt. Defaults to 0</param>
29+ /// <param name="cancellationToken">Specifies a token by which the wait can be canceled</param>
30+ /// <returns>An <see cref="EtcdLeaseDistributedLockHandle"/> which can be used to release the lock or null on failure</returns>
31+ public EtcdLeaseDistributedLockHandle ? TryAcquire ( TimeSpan timeout = default , CancellationToken cancellationToken = default ) =>
32+ DistributedLockHelpers . TryAcquire ( this , timeout , cancellationToken ) ;
33+
34+ /// <summary>
35+ /// Acquires the lock synchronously, failing with <see cref="TimeoutException"/> if the attempt times out. Usage:
36+ /// <code>
37+ /// using (myLock.Acquire(...))
38+ /// {
39+ /// /* we have the lock! */
40+ /// }
41+ /// // dispose releases the lock
42+ /// </code>
43+ /// </summary>
44+ /// <param name="timeout">How long to wait before giving up on the acquisition attempt. Defaults to <see cref="Timeout.InfiniteTimeSpan"/></param>
45+ /// <param name="cancellationToken">Specifies a token by which the wait can be canceled</param>
46+ /// <returns>An <see cref="EtcdLeaseDistributedLockHandle"/> which can be used to release the lock</returns>
47+ public EtcdLeaseDistributedLockHandle Acquire ( TimeSpan ? timeout = null , CancellationToken cancellationToken = default ) =>
48+ DistributedLockHelpers . Acquire ( this , timeout , cancellationToken ) ;
49+
50+ /// <summary>
51+ /// Attempts to acquire the lock asynchronously. Usage:
52+ /// <code>
53+ /// await using (var handle = await myLock.TryAcquireAsync(...))
54+ /// {
55+ /// if (handle != null) { /* we have the lock! */ }
56+ /// }
57+ /// // dispose releases the lock if we took it
58+ /// </code>
59+ /// </summary>
60+ /// <param name="timeout">How long to wait before giving up on the acquisition attempt. Defaults to 0</param>
61+ /// <param name="cancellationToken">Specifies a token by which the wait can be canceled</param>
62+ /// <returns>An <see cref="EtcdLeaseDistributedLockHandle"/> which can be used to release the lock or null on failure</returns>
63+ public ValueTask < EtcdLeaseDistributedLockHandle ? > TryAcquireAsync ( TimeSpan timeout = default , CancellationToken cancellationToken = default ) =>
64+ this . As < IInternalDistributedLock < EtcdLeaseDistributedLockHandle > > ( ) . InternalTryAcquireAsync ( timeout , cancellationToken ) ;
65+
66+ /// <summary>
67+ /// Acquires the lock asynchronously, failing with <see cref="TimeoutException"/> if the attempt times out. Usage:
68+ /// <code>
69+ /// await using (await myLock.AcquireAsync(...))
70+ /// {
71+ /// /* we have the lock! */
72+ /// }
73+ /// // dispose releases the lock
74+ /// </code>
75+ /// </summary>
76+ /// <param name="timeout">How long to wait before giving up on the acquisition attempt. Defaults to <see cref="Timeout.InfiniteTimeSpan"/></param>
77+ /// <param name="cancellationToken">Specifies a token by which the wait can be canceled</param>
78+ /// <returns>An <see cref="EtcdLeaseDistributedLockHandle"/> which can be used to release the lock</returns>
79+ public ValueTask < EtcdLeaseDistributedLockHandle > AcquireAsync ( TimeSpan ? timeout = null , CancellationToken cancellationToken = default ) =>
80+ DistributedLockHelpers . AcquireAsync ( this , timeout , cancellationToken ) ;
81+ }
0 commit comments