@@ -46,7 +46,7 @@ internal TypeAdapterConfig(bool IsGlobal) : this()
4646 public TypeAdapterConfig ( )
4747 {
4848 Configure = new ( true ) ;
49- AdaptMutex = new ( false ) ;
49+ AdaptMutex = new ( true ) ;
5050 Rules = TypeAdapterConfigFactory . RulesTemplate . ToList ( ) ;
5151 var settings = new TypeAdapterSettings ( ) ;
5252 ConfigCompile = new ConfigCompileStorage ( this ) ;
@@ -66,15 +66,6 @@ public TypeAdapterConfig()
6666 /// <returns></returns>
6767 public TypeAdapterSetter ForType ( Type sourceType , Type destinationType )
6868 {
69- if ( ConcurencyEnviroment &&
70- WaitHandle . WaitAll ( new WaitHandle [ ] { AdaptMutex , Configure } , 0 , false ) )
71- {
72- AdaptMutex . Reset ( ) ;
73- Configure . Set ( ) ;
74- Configure . WaitOne ( ) ;
75- }
76-
77-
7869 var key = new TypeTuple ( sourceType , destinationType ) ;
7970 var settings = this . GetSettings ( key ) ;
8071 return new TypeAdapterSetter ( settings , this ) ;
@@ -88,28 +79,17 @@ public TypeAdapterSetter ForType(Type sourceType, Type destinationType)
8879 /// <returns></returns>
8980 public TypeAdapterSetter < TSource , TDestination > ForType < TSource , TDestination > ( )
9081 {
91-
92-
93- if ( ConcurencyEnviroment &&
94- WaitHandle . WaitAll ( new WaitHandle [ ] { AdaptMutex , Configure } , 0 , false ) )
95- {
96- AdaptMutex . Reset ( ) ;
97- Configure . Set ( ) ;
98- Configure . WaitOne ( ) ;
99- }
100-
10182 var key = new TypeTuple ( typeof ( TSource ) , typeof ( TDestination ) ) ;
10283 var settings = this . GetSettings ( key ) ;
10384 return new TypeAdapterSetter < TSource , TDestination > ( settings , this ) ;
10485 }
10586
10687 public LambdaExpression CreateMapExpression ( TypeTuple tuple , MapType mapType )
10788 {
108- if ( ConcurencyEnviroment && WaitHandle . WaitAll ( new WaitHandle [ ] { AdaptMutex , Configure } ) )
89+ if ( ConcurencyEnviroment )
10990 {
110- AdaptMutex . Set ( ) ;
111- Configure . Reset ( ) ;
112- AdaptMutex . WaitOne ( ) ;
91+ Configure . WaitOne ( - 1 ) ;
92+ AdaptMutex . WaitOne ( - 1 , false ) ;
11393 }
11494
11595 var context = new CompileContext ( this ) ;
0 commit comments