Skip to content

Commit ed08923

Browse files
authored
Use the new more efficient .NET 9 Lock type (#18015)
1 parent 87916eb commit ed08923

File tree

32 files changed

+37
-37
lines changed

32 files changed

+37
-37
lines changed

src/Umbraco.Core/Cache/ValueEditorCache.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ namespace Umbraco.Cms.Core.Cache;
55

66
public class ValueEditorCache : IValueEditorCache
77
{
8-
private readonly object _dictionaryLocker;
8+
private readonly Lock _dictionaryLocker;
99
private readonly Dictionary<string, Dictionary<int, IDataValueEditor>> _valueEditorCache;
1010

1111
public ValueEditorCache()
1212
{
1313
_valueEditorCache = new Dictionary<string, Dictionary<int, IDataValueEditor>>();
14-
_dictionaryLocker = new object();
14+
_dictionaryLocker = new Lock();
1515
}
1616

1717
public IDataValueEditor GetValueEditor(IDataEditor editor, IDataType dataType)

src/Umbraco.Core/Composing/CollectionBuilderBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public abstract class CollectionBuilderBase<TBuilder, TCollection, TItem> : ICol
1313
where TBuilder : CollectionBuilderBase<TBuilder, TCollection, TItem>
1414
where TCollection : class, IBuilderCollection<TItem>
1515
{
16-
private readonly object _locker = new();
16+
private readonly Lock _locker = new();
1717
private readonly List<Type> _types = new();
1818
private Type[]? _registeredTypes;
1919

src/Umbraco.Core/Composing/TypeFinder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class TypeFinder : ITypeFinder
4040
private static readonly ConcurrentDictionary<string, Type?> TypeNamesCache = new();
4141

4242
private readonly IAssemblyProvider _assemblyProvider;
43-
private readonly object _localFilteredAssemblyCacheLocker = new();
43+
private readonly Lock _localFilteredAssemblyCacheLocker = new();
4444
private readonly ILogger<TypeFinder> _logger;
4545
private readonly List<string> _notifiedLoadExceptionAssemblies = new();
4646

src/Umbraco.Core/Composing/TypeLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace Umbraco.Cms.Core.Composing;
2020
/// </remarks>
2121
public sealed class TypeLoader
2222
{
23-
private readonly object _locko = new();
23+
private readonly Lock _locko = new();
2424
private readonly ILogger<TypeLoader> _logger;
2525

2626
private readonly Dictionary<CompositeTypeTypeKey, TypeList> _types = new();

src/Umbraco.Core/Diagnostics/MiniDump.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Umbraco.Cms.Core.Diagnostics;
99
// which itself got it from http://blog.kalmbach-software.de/2008/12/13/writing-minidumps-in-c/
1010
public static class MiniDump
1111
{
12-
private static readonly object LockO = new();
12+
private static readonly Lock LockO = new();
1313

1414
[Flags]
1515
public enum Option : uint

src/Umbraco.Core/Events/ScopedNotificationPublisher.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class ScopedNotificationPublisher<TNotificationHandler> : IScopedNotifica
1818
private readonly IEventAggregator _eventAggregator;
1919
private readonly List<INotification> _notificationOnScopeCompleted = new List<INotification>();
2020
private readonly bool _publishCancelableNotificationOnScopeExit;
21-
private readonly object _locker = new();
21+
private readonly Lock _locker = new();
2222
private bool _isSuppressed;
2323

2424
public ScopedNotificationPublisher(IEventAggregator eventAggregator, bool publishCancelableNotificationOnScopeExit = false)

src/Umbraco.Core/Extensions/WaitHandleExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public static class WaitHandleExtensions
1212
public static Task WaitOneAsync(this WaitHandle handle, int millisecondsTimeout = Timeout.Infinite)
1313
{
1414
var tcs = new TaskCompletionSource<object?>();
15-
var callbackHandleInitLock = new object();
15+
var callbackHandleInitLock = new Lock();
1616
lock (callbackHandleInitLock)
1717
{
1818
RegisteredWaitHandle? callbackHandle = null;

src/Umbraco.Core/IO/FileSystems.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public sealed class FileSystems
3131

3232
// shadow support
3333
private readonly List<ShadowWrapper> _shadowWrappers = new();
34-
private readonly object _shadowLocker = new();
34+
private readonly Lock _shadowLocker = new();
3535
private static string? _shadowCurrentId; // static - unique!!
3636
#region Constructor
3737

src/Umbraco.Core/Models/PropertyCollection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Umbraco.Cms.Core.Models;
1313
[DataContract(IsReference = true)]
1414
public class PropertyCollection : KeyedCollection<string, IProperty>, IPropertyCollection
1515
{
16-
private readonly object _addLocker = new();
16+
private readonly Lock _addLocker = new();
1717

1818
/// <summary>
1919
/// Initializes a new instance of the <see cref="PropertyCollection" /> class.

src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class PublishedPropertyType : IPublishedPropertyType
1414
{
1515
private readonly IPublishedModelFactory _publishedModelFactory;
1616
private readonly PropertyValueConverterCollection _propertyValueConverters;
17-
private readonly object _locker = new object();
17+
private readonly Lock _locker = new();
1818
private volatile bool _initialized;
1919
private IPropertyValueConverter? _converter;
2020
private PropertyCacheLevel _cacheLevel;

0 commit comments

Comments
 (0)