// // 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 WriteLock : IDisposable { private readonly ReaderWriterLockSlim readerWriterLockSlim; /// /// Initializes a new instance of the class. /// /// The reader writer lock slim. public WriteLock(ReaderWriterLockSlim readerWriterLockSlim) { this.readerWriterLockSlim = readerWriterLockSlim; readerWriterLockSlim.EnterWriteLock(); } /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// public void Dispose() { this.readerWriterLockSlim.ExitWriteLock(); } } }