Skip to content

Commit 3383e05

Browse files
committed
drop ApplySync
1 parent a05b56c commit 3383e05

File tree

1 file changed

+2
-27
lines changed

1 file changed

+2
-27
lines changed

src/Mapster/TypeAdapterConfig.cs

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ public class TypeAdapterConfig
1919
[AdaptIgnore]
2020
internal AutoResetEvent ConfigureSync { get; set; }
2121

22-
[AdaptIgnore]
23-
internal AutoResetEvent ApplySync { get; set; }
24-
internal bool IsScanConcurrency { get; set; }
25-
2622
#endregion ConcurrencyMod
2723

2824
public static List<TypeAdapterRule> RulesTemplate { get; } = CreateRuleTemplate();
@@ -108,8 +104,7 @@ private static List<TypeAdapterRule> CreateRuleTemplate()
108104
public TypeAdapterConfig()
109105
{
110106
ConfigureSync = new(true);
111-
ApplySync = new(true);
112-
107+
113108
Rules = RulesTemplate.ToList();
114109
var settings = new TypeAdapterSettings();
115110
Default = new TypeAdapterSetter(settings, this);
@@ -339,8 +334,6 @@ internal Delegate GetMapFunction(Type sourceType, Type destinationType)
339334
{
340335
ConfigureSync.WaitOne();
341336

342-
if (IsScanConcurrency)
343-
ApplySync.WaitOne();
344337
try
345338
{
346339
var key = new TypeTuple(sourceType, destinationType);
@@ -350,7 +343,6 @@ internal Delegate GetMapFunction(Type sourceType, Type destinationType)
350343
}
351344
finally
352345
{
353-
ApplySync.Set();
354346
ConfigureSync.Set();
355347
}
356348
}
@@ -364,9 +356,6 @@ internal Delegate GetMapToTargetFunction(Type sourceType, Type destinationType)
364356
{
365357
ConfigureSync.WaitOne();
366358

367-
if (IsScanConcurrency)
368-
ApplySync.WaitOne();
369-
370359
try
371360
{
372361
var key = new TypeTuple(sourceType, destinationType);
@@ -376,7 +365,6 @@ internal Delegate GetMapToTargetFunction(Type sourceType, Type destinationType)
376365
}
377366
finally
378367
{
379-
ApplySync.Set();
380368
ConfigureSync.Set();
381369
}
382370

@@ -393,9 +381,6 @@ internal MethodCallExpression GetProjectionCallExpression(Type sourceType, Type
393381
{
394382
ConfigureSync.WaitOne();
395383

396-
if (IsScanConcurrency)
397-
ApplySync.WaitOne();
398-
399384
try
400385
{
401386
var key = new TypeTuple(sourceType, destinationType);
@@ -405,7 +390,6 @@ internal MethodCallExpression GetProjectionCallExpression(Type sourceType, Type
405390
}
406391
finally
407392
{
408-
ApplySync.Set();
409393
ConfigureSync.Set();
410394
}
411395
}
@@ -415,9 +399,6 @@ public Func<object, TDestination> GetDynamicMapFunction<TDestination>(Type sourc
415399
{
416400
ConfigureSync.WaitOne();
417401

418-
if (IsScanConcurrency)
419-
ApplySync.WaitOne(-1);
420-
421402
try
422403
{
423404
var key = new TypeTuple(sourceType, typeof(TDestination));
@@ -427,7 +408,6 @@ public Func<object, TDestination> GetDynamicMapFunction<TDestination>(Type sourc
427408
}
428409
finally
429410
{
430-
ApplySync.Set();
431411
ConfigureSync.Set();
432412
}
433413
}
@@ -809,8 +789,7 @@ public IList<IRegister> Scan(params Assembly[] assemblies)
809789
public IList<IRegister> ScanConcurrency(params Assembly[] assemblies)
810790
{
811791
ConfigureSync.WaitOne();
812-
IsScanConcurrency = true;
813-
792+
814793
try
815794
{
816795
return Scan(assemblies);
@@ -837,14 +816,10 @@ public void Apply(IEnumerable<Lazy<IRegister>> registers)
837816
/// <param name="registers">collection of IRegister interface to apply mapping.</param>
838817
public void Apply(IEnumerable<IRegister> registers)
839818
{
840-
ApplySync.WaitOne();
841-
842819
foreach (IRegister register in registers)
843820
{
844821
register.Register(this);
845822
}
846-
847-
ApplySync.Set();
848823
}
849824

850825

0 commit comments

Comments
 (0)