Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make use of System.Threading.Lock #20530

Open
wants to merge 19 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<PackageVersion Include="AWSSDK.SecurityToken" Version="3.7.400.30" />
<PackageVersion Include="Azure.Messaging.ServiceBus" Version="7.18.1" />
<PackageVersion Include="Azure.Storage.Blobs" Version="12.22.1" />
<PackageVersion Include="Backport.System.Threading.Lock" Version="2.0.5" />
<PackageVersion Include="Blazorise" Version="1.6.1" />
<PackageVersion Include="Blazorise.Components" Version="1.6.1" />
<PackageVersion Include="Blazorise.DataGrid" Version="1.6.1" />
Expand Down
14 changes: 14 additions & 0 deletions framework/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />

<PropertyGroup>
<LangVersion>preview</LangVersion>
</PropertyGroup>

<ItemGroup>
<Using Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net9.0'))" Alias="Lock" Include="System.Threading.Lock" />
<Using Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net9.0'))" Alias="Lock" Include="Backport.System.Threading.Lock" />
<Using Alias="LockFactory" Include="Backport.System.Threading.LockFactory" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Volo.Abp.AspNetCore.Components.Web.ExceptionHandling;
public class AbpExceptionHandlingLoggerProvider : ILoggerProvider
{
private AbpExceptionHandlingLogger? _logger;
private static readonly object SyncObj = new object();
private static readonly Lock SyncObj = new();
private readonly IServiceCollection _serviceCollection;

public AbpExceptionHandlingLoggerProvider(IServiceCollection serviceCollection)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class CachedObjectExtensionsDtoService : ICachedObjectExtensionsDtoServic
{
protected IExtensionPropertyAttributeDtoFactory ExtensionPropertyAttributeDtoFactory { get; }
protected volatile ObjectExtensionsDto? CachedValue;
protected readonly object SyncLock = new object();
protected readonly Lock SyncLock = new();

public CachedObjectExtensionsDtoService(IExtensionPropertyAttributeDtoFactory extensionPropertyAttributeDtoFactory)
{
Expand Down
1 change: 1 addition & 0 deletions framework/src/Volo.Abp.Core/Volo.Abp.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Backport.System.Threading.Lock" />
<PackageReference Include="System.Collections.Immutable" />
<PackageReference Include="Microsoft.Extensions.Localization" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Localization;
Expand All @@ -19,7 +18,7 @@ public abstract class VirtualFileLocalizationResourceContributorBase : ILocaliza
private IVirtualFileProvider _virtualFileProvider = default!;
private Dictionary<string, ILocalizationDictionary>? _dictionaries;
private bool _subscribedForChanges;
private readonly object _syncObj = new object();
private readonly Lock _syncObj = LockFactory.Create();
private LocalizationResourceBase _resource = default!;

protected VirtualFileLocalizationResourceContributorBase(string virtualPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class MongoModelBuilder : IMongoModelBuilder
{
private readonly Dictionary<Type, object> _entityModelBuilders;

private static readonly object SyncObj = new object();
private static readonly Lock SyncObj = LockFactory.Create();

public MongoModelBuilder()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="..\..\..\configureawait.props" />
<Import Project="..\..\..\common.props" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Volo.Abp.ObjectExtending.Modularity;

public static class ModuleExtensionConfigurationHelper
{
private static object SyncLock = new object();
private static Lock SyncLock = LockFactory.Create();

public static void ApplyEntityConfigurationToEntity(
string moduleName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class RabbitMqMessageConsumer : IRabbitMqMessageConsumer, ITransientDepen

protected ConcurrentQueue<QueueBindCommand> QueueBindCommands { get; }

protected object ChannelSendSyncLock { get; } = new object();
protected Lock ChannelSendSyncLock { get; } = LockFactory.Create();

public RabbitMqMessageConsumer(
IConnectionPool connectionPool,
Expand Down
Loading