/// <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>
 /// <param name="timeout">The amount of time to wait for the lock.</param>
 /// <returns>The acquired read lock.</returns>
 /// <exception cref="TimeoutException">The lock cannot be acquired during the specified amount of time.</exception>
 public static Lock.Holder AcquireReadLock <T>(this T obj, TimeSpan timeout)
     where T : class => Lock.ReadLock(obj.GetReaderWriterLock(), false).Acquire(timeout);
 /// <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();
 /// <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();