//
// Copyright (c) Moonfire Games.
// This code is licensed under the MIT license.
// See LICENSE.md in the source or https://opensource.org/licenses/MIT
//
namespace MfGames.Locking
{
using System;
using System.Threading;
///
/// Defines a ReaderWriterLockSlim read-only lock.
///
public class UpgradableLock : IDisposable
{
private readonly ReaderWriterLockSlim readerWriterLockSlim;
///
/// Initializes a new instance of the class.
///
/// The reader writer lock slim.
public UpgradableLock(ReaderWriterLockSlim readerWriterLockSlim)
{
this.readerWriterLockSlim = readerWriterLockSlim;
readerWriterLockSlim.EnterUpgradeableReadLock();
}
///
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
///
public void Dispose()
{
this.readerWriterLockSlim.ExitUpgradeableReadLock();
}
}
}