Beispiel #1
0
 /// <summary>
 /// Acquires upgradeable read lock for the specified object.
 /// </summary>
 /// <typeparam name="T">The type of the object to be locked.</typeparam>
 /// <param name="obj">The object to be locked.</param>
 /// <returns>The acquired upgradeable read lock.</returns>
 public static Lock.Holder AcquireUpgradeableReadLock <T>(this T obj) where T : class =>
 Lock.ReadLock(obj.GetReaderWriterLock(), true).Acquire();
Beispiel #2
0
 /// <summary>
 /// Acquires write lock for the specified object.
 /// </summary>
 /// <typeparam name="T">The type of the object to be locked.</typeparam>
 /// <param name="obj">The object to be locked.</param>
 /// <returns>The acquired write lock.</returns>
 public static Lock.Holder AcquireWriteLock <T>(this T obj) where T : class =>
 Lock.WriteLock(obj.GetReaderWriterLock()).Acquire();
Beispiel #3
0
 /// <summary>
 /// Acquires write lock for the specified object.
 /// </summary>
 /// <typeparam name="T">The type of the object to be locked.</typeparam>
 /// <param name="obj">The object to be locked.</param>
 /// <param name="timeout">The amount of time to wait for the lock.</param>
 /// <returns>The acquired write lock.</returns>
 /// <exception cref="TimeoutException">The lock cannot be acquired during the specified amount of time.</exception>
 public static Lock.Holder AcquireWriteLock <T>(this T obj, TimeSpan timeout) where T : class =>
 Lock.WriteLock(obj.GetReaderWriterLock()).Acquire(timeout);
Beispiel #4
0
 /// <summary>
 /// Acquires read lock for the specified object.
 /// </summary>
 /// <typeparam name="T">The type of the object to be locked.</typeparam>
 /// <param name="obj">The object to be locked.</param>
 /// <returns>The acquired read lock.</returns>
 public static Lock.Holder AcquireReadLock <T>(this T obj) where T : class =>
 Lock.ReadLock(obj.GetReaderWriterLock(), false).Acquire();