@@ -14,7 +14,7 @@ public class InterlockedArrayObjectPool<T> : ObjectPoolBase<T>
1414 where T : class
1515 {
1616
17- public InterlockedArrayObjectPool ( Func < T > factory , Action < T > recycler , Action < T > disposer , int capacity = DEFAULT_CAPACITY )
17+ public InterlockedArrayObjectPool ( Func < T > factory , Action < T > ? recycler , Action < T > ? disposer , int capacity = DEFAULT_CAPACITY )
1818 : base ( factory , recycler , disposer , capacity )
1919 {
2020 Pool = new ReferenceContainer < T > [ capacity - 1 ] ;
@@ -33,6 +33,7 @@ public InterlockedArrayObjectPool(Func<T> factory, int capacity = DEFAULT_CAPACI
3333 public override int Count
3434 => Pool . Count ( e => e . Value != null ) + PocketCount ;
3535
36+ [ System . Diagnostics . CodeAnalysis . SuppressMessage ( "Design" , "CA1062:Validate arguments of public methods" , Justification = "Should never be null." ) ]
3637 protected virtual bool Store ( ReferenceContainer < T > [ ] p , T item , int index )
3738 => p [ index ] . TrySave ( item ) ;
3839
@@ -43,7 +44,7 @@ protected override bool Receive(T item)
4344
4445 for ( var i = 0 ; i < len ; i ++ )
4546 {
46- if ( Store ( elements , item , i ) )
47+ if ( Store ( elements ! , item , i ) )
4748 {
4849 var m = MaxStored ;
4950 if ( i >= m ) Interlocked . CompareExchange ( ref MaxStored , m + MaxStoredIncrement , m ) ;
@@ -55,7 +56,7 @@ protected override bool Receive(T item)
5556 return false ;
5657 }
5758
58- protected override T TryRelease ( )
59+ protected override T ? TryRelease ( )
5960 {
6061 // We missed getting the first item or it wasn't there.
6162 var elements = Pool ;
@@ -74,7 +75,7 @@ protected override T TryRelease()
7475 protected override void OnDispose ( )
7576 {
7677 base . OnDispose ( ) ;
77- Pool = null ;
78+ Pool = null ! ;
7879 MaxStored = 0 ;
7980 }
8081
0 commit comments