merge
This commit is contained in:
@@ -12,29 +12,22 @@ namespace Umbraco.Core
|
||||
/// <remarks>
|
||||
/// Intended as an infrastructure class.
|
||||
/// </remarks>
|
||||
public class UpgradeableReadLock : IDisposable
|
||||
public class ReadLock : IDisposable
|
||||
{
|
||||
private readonly ReaderWriterLockSlim _rwLock;
|
||||
private bool _upgraded = false;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ReadLock"/> class.
|
||||
/// </summary>
|
||||
/// <param name="rwLock">The rw lock.</param>
|
||||
public UpgradeableReadLock(ReaderWriterLockSlim rwLock)
|
||||
public ReadLock(ReaderWriterLockSlim rwLock)
|
||||
{
|
||||
_rwLock = rwLock;
|
||||
_rwLock.EnterUpgradeableReadLock();
|
||||
_rwLock.EnterReadLock();
|
||||
}
|
||||
|
||||
public void UpgradeToWriteLock()
|
||||
{
|
||||
_rwLock.EnterWriteLock();
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
_rwLock.ExitUpgradeableReadLock();
|
||||
_rwLock.ExitReadLock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,8 +53,8 @@
|
||||
<Compile Include="Resolving\SingleResolved.cs" />
|
||||
<Compile Include="Resolving\SingleResolverBase.cs" />
|
||||
<Compile Include="TypeExtensions.cs" />
|
||||
<Compile Include="UpgradeableReadLock.cs" />
|
||||
<Compile Include="ReadLock.cs" />
|
||||
<Compile Include="UpgradeableReadLock.cs" />
|
||||
<Compile Include="DelegateEqualityComparer.cs" />
|
||||
<Compile Include="EnumerableExtensions.cs" />
|
||||
<Compile Include="IfExtensions.cs" />
|
||||
@@ -71,7 +71,6 @@
|
||||
<Name>umbraco.businesslogic</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
@@ -12,23 +12,34 @@ namespace Umbraco.Core
|
||||
/// <remarks>
|
||||
/// Intended as an infrastructure class.
|
||||
/// </remarks>
|
||||
public class ReadLock : IDisposable
|
||||
public class UpgradeableReadLock : IDisposable
|
||||
{
|
||||
private readonly ReaderWriterLockSlim _rwLock;
|
||||
private bool _upgraded = false;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ReadLock"/> class.
|
||||
/// </summary>
|
||||
/// <ReadLock name="rwLock">The rw lock.</param>
|
||||
public ReadLock(ReaderWriterLockSlim rwLock)
|
||||
/// <param name="rwLock">The rw lock.</param>
|
||||
public UpgradeableReadLock(ReaderWriterLockSlim rwLock)
|
||||
{
|
||||
_rwLock = rwLock;
|
||||
_rwLock.EnterReadLock();
|
||||
_rwLock.EnterUpgradeableReadLock();
|
||||
}
|
||||
|
||||
public void UpgradeToWriteLock()
|
||||
{
|
||||
_rwLock.EnterWriteLock();
|
||||
_upgraded = true;
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
_rwLock.ExitReadLock();
|
||||
if (_upgraded)
|
||||
{
|
||||
_rwLock.ExitWriteLock();
|
||||
}
|
||||
_rwLock.ExitUpgradeableReadLock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user