1 type derived from ObjectPool
Microsoft.CodeAnalysis (1)
DocumentationCommentId.cs (1)
22private class ListPool<T> : ObjectPool<List<T>>
31 instantiations of ObjectPool
Microsoft.CodeAnalysis (31)
CodeGen\BasicBlock.cs (1)
59return new ObjectPool<BasicBlock>(() => new PooledBasicBlock(), size);
Collections\CachingFactory.cs (1)
198var pool = new ObjectPool<CachingIdentityFactory<TKey, TValue>>(
Collections\OrderPreservingMultiDictionary.cs (1)
60var pool = new ObjectPool<OrderPreservingMultiDictionary<K, V>>(
CommandLine\AnalyzerConfigSet.cs (3)
55new ObjectPool<TreeOptions.Builder>(() => ImmutableDictionary.CreateBuilder<string, ReportDiagnostic>(Section.PropertiesKeyComparer)); 58new ObjectPool<AnalyzerOptions.Builder>(() => ImmutableDictionary.CreateBuilder<string, string>(Section.PropertiesKeyComparer)); 60private readonly ObjectPool<List<Section>> _sectionKeyPool = new ObjectPool<List<Section>>(() => new List<Section>());
Diagnostic\DiagnosticBag.cs (1)
339return new ObjectPool<DiagnosticBag>(() => new DiagnosticBag(), size);
DiagnosticAnalyzer\AnalyzerExecutor.AnalyzerDiagnosticReporter.cs (1)
25new ObjectPool<AnalyzerDiagnosticReporter>(() => new AnalyzerDiagnosticReporter(), 10);
DocumentationComments\XmlDocumentationCommentTextReader.cs (1)
24new ObjectPool<XmlDocumentationCommentTextReader>(() => new XmlDocumentationCommentTextReader(), size: 2);
InternalUtilities\BlobBuildingStream.cs (1)
20private static readonly ObjectPool<BlobBuildingStream> s_pool = new ObjectPool<BlobBuildingStream>(() => new BlobBuildingStream());
InternalUtilities\StringTable.cs (1)
94var pool = new ObjectPool<StringTable>(pool => new StringTable(pool), Environment.ProcessorCount * 2);
InternalUtilities\TextKeyedCache.cs (1)
86var pool = new ObjectPool<TextKeyedCache<T>>(
PEWriter\PooledBlobBuilder.cs (1)
20private static readonly ObjectPool<PooledBlobBuilder> s_chunkPool = new ObjectPool<PooledBlobBuilder>(() => new PooledBlobBuilder(PoolChunkSize), PoolSize);
ReferenceManager\CommonReferenceManager.Binding.cs (3)
19new ObjectPool<MultiDictionary<string, (AssemblyData DefinitionData, int DefinitionIndex)>>(() => new MultiDictionary<string, (AssemblyData DefinitionData, int DefinitionIndex)>(AssemblyIdentityComparer.SimpleNameComparer)); 723private static readonly ObjectPool<Queue<AssemblyReferenceCandidate>> s_candidatesToExaminePool = new ObjectPool<Queue<AssemblyReferenceCandidate>>(() => new Queue<AssemblyReferenceCandidate>()); 724private static readonly ObjectPool<List<TAssemblySymbol?>> s_candidateReferencedSymbolsPool = new ObjectPool<List<TAssemblySymbol?>>(() => new List<TAssemblySymbol?>(capacity: 1024));
SourceGeneration\Nodes\SyntaxValueProvider_ForAttributeWithSimpleName.cs (2)
31private static readonly ObjectPool<Stack<string>> s_stringStackPool = new ObjectPool<Stack<string>>(static () => new Stack<string>()); 32private static readonly ObjectPool<Stack<SyntaxNode>> s_nodeStackPool = new ObjectPool<Stack<SyntaxNode>>(static () => new Stack<SyntaxNode>());
src\Dependencies\PooledObjects\ArrayBuilder.cs (1)
495pool = new ObjectPool<ArrayBuilder<T>>(() => new ArrayBuilder<T>(pool!), size);
src\Dependencies\PooledObjects\PooledDelegates.cs (1)
19public static readonly ObjectPool<T> Instance = new(() => new T(), 20);
src\Dependencies\PooledObjects\PooledDictionary.cs (1)
46pool = new ObjectPool<PooledDictionary<K, V>>(() => new PooledDictionary<K, V>(pool!, keyComparer), 128);
src\Dependencies\PooledObjects\PooledHashSet.cs (1)
35pool = new ObjectPool<PooledHashSet<T>>(() => new PooledHashSet<T>(pool!, equalityComparer), 128);
src\Dependencies\PooledObjects\PooledStringBuilder.cs (1)
84pool = new ObjectPool<PooledStringBuilder>(() => new PooledStringBuilder(pool!), size);
Syntax\SyntaxNavigator.cs (2)
93= new ObjectPool<Stack<ChildSyntaxList.Enumerator>>(() => new Stack<ChildSyntaxList.Enumerator>(), 10); 139= new ObjectPool<Stack<ChildSyntaxList.Reversed.Enumerator>>(() => new Stack<ChildSyntaxList.Reversed.Enumerator>(), 10);
Syntax\SyntaxNode.Iterators.cs (2)
47private static readonly ObjectPool<ChildSyntaxList.Enumerator[]> s_stackPool = new ObjectPool<ChildSyntaxList.Enumerator[]>(() => new ChildSyntaxList.Enumerator[16]); 133private static readonly ObjectPool<SyntaxTriviaList.Enumerator[]> s_stackPool = new ObjectPool<SyntaxTriviaList.Enumerator[]>(() => new SyntaxTriviaList.Enumerator[16]);
Syntax\SyntaxTriviaList.cs (1)
292new ObjectPool<SyntaxTriviaListBuilder>(() => SyntaxTriviaListBuilder.Create());
Text\CompositeText.cs (1)
364= new ObjectPool<HashSet<SourceText>>(() => new HashSet<SourceText>(), 5);
Text\SourceText.cs (2)
33private static readonly ObjectPool<char[]> s_charArrayPool = new ObjectPool<char[]>(() => new char[CharBufferSize], CharBufferCount); 34private static readonly ObjectPool<XxHash128> s_contentHashPool = new ObjectPool<XxHash128>(() => new XxHash128());
69 references to ObjectPool
Microsoft.CodeAnalysis (69)
CodeGen\BasicBlock.cs (2)
56public static readonly ObjectPool<BasicBlock> Pool = CreatePool(32); 57private static ObjectPool<BasicBlock> CreatePool(int size)
Collections\CachingFactory.cs (5)
132private readonly ObjectPool<CachingIdentityFactory<TKey, TValue>>? _pool; 146public CachingIdentityFactory(int size, Func<TKey, TValue> valueFactory, ObjectPool<CachingIdentityFactory<TKey, TValue>> pool) : 196public static ObjectPool<CachingIdentityFactory<TKey, TValue>> CreatePool(int size, Func<TKey, TValue> valueFactory) 198var pool = new ObjectPool<CachingIdentityFactory<TKey, TValue>>( 207var pool = _pool;
Collections\OrderPreservingMultiDictionary.cs (5)
30private readonly ObjectPool<OrderPreservingMultiDictionary<K, V>>? _pool; 32private OrderPreservingMultiDictionary(ObjectPool<OrderPreservingMultiDictionary<K, V>> pool) 55private static readonly ObjectPool<OrderPreservingMultiDictionary<K, V>> s_poolInstance = CreatePool(); 58public static ObjectPool<OrderPreservingMultiDictionary<K, V>> CreatePool() 60var pool = new ObjectPool<OrderPreservingMultiDictionary<K, V>>(
CommandLine\AnalyzerConfigSet.cs (4)
54private readonly ObjectPool<TreeOptions.Builder> _treeOptionsPool = 57private readonly ObjectPool<AnalyzerOptions.Builder> _analyzerOptionsPool = 60private readonly ObjectPool<List<Section>> _sectionKeyPool = new ObjectPool<List<Section>>(() => new List<Section>()); 324static void freeKey(List<Section> sectionKey, ObjectPool<List<Section>> pool)
Diagnostic\DiagnosticBag.cs (2)
336private static readonly ObjectPool<DiagnosticBag> s_poolInstance = CreatePool(128); 337private static ObjectPool<DiagnosticBag> CreatePool(int size)
DiagnosticAnalyzer\AnalyzerExecutor.AnalyzerDiagnosticReporter.cs (1)
24private static readonly ObjectPool<AnalyzerDiagnosticReporter> s_objectPool =
DocumentationComments\XmlDocumentationCommentTextReader.cs (1)
23private static readonly ObjectPool<XmlDocumentationCommentTextReader> s_pool =
InternalUtilities\BlobBuildingStream.cs (1)
20private static readonly ObjectPool<BlobBuildingStream> s_pool = new ObjectPool<BlobBuildingStream>(() => new BlobBuildingStream());
InternalUtilities\StringTable.cs (5)
84private StringTable(ObjectPool<StringTable>? pool) 89private readonly ObjectPool<StringTable>? _pool; 90private static readonly ObjectPool<StringTable> s_staticPool = CreatePool(); 92private static ObjectPool<StringTable> CreatePool() 94var pool = new ObjectPool<StringTable>(pool => new StringTable(pool), Environment.ProcessorCount * 2);
InternalUtilities\TextKeyedCache.cs (5)
75private TextKeyedCache(ObjectPool<TextKeyedCache<T>>? pool) 81private readonly ObjectPool<TextKeyedCache<T>>? _pool; 82private static readonly ObjectPool<TextKeyedCache<T>> s_staticPool = CreatePool(); 84private static ObjectPool<TextKeyedCache<T>> CreatePool() 86var pool = new ObjectPool<TextKeyedCache<T>>(
PEWriter\PooledBlobBuilder.cs (1)
20private static readonly ObjectPool<PooledBlobBuilder> s_chunkPool = new ObjectPool<PooledBlobBuilder>(() => new PooledBlobBuilder(PoolChunkSize), PoolSize);
ReferenceManager\CommonReferenceManager.Binding.cs (3)
18private static readonly ObjectPool<MultiDictionary<string, (AssemblyData DefinitionData, int DefinitionIndex)>> s_pool = 723private static readonly ObjectPool<Queue<AssemblyReferenceCandidate>> s_candidatesToExaminePool = new ObjectPool<Queue<AssemblyReferenceCandidate>>(() => new Queue<AssemblyReferenceCandidate>()); 724private static readonly ObjectPool<List<TAssemblySymbol?>> s_candidateReferencedSymbolsPool = new ObjectPool<List<TAssemblySymbol?>>(() => new List<TAssemblySymbol?>(capacity: 1024));
SourceGeneration\Nodes\SyntaxValueProvider_ForAttributeWithSimpleName.cs (2)
31private static readonly ObjectPool<Stack<string>> s_stringStackPool = new ObjectPool<Stack<string>>(static () => new Stack<string>()); 32private static readonly ObjectPool<Stack<SyntaxNode>> s_nodeStackPool = new ObjectPool<Stack<SyntaxNode>>(static () => new Stack<SyntaxNode>());
src\Dependencies\PooledObjects\ArrayBuilder.cs (7)
56private readonly ObjectPool<ArrayBuilder<T>>? _pool; 67private ArrayBuilder(ObjectPool<ArrayBuilder<T>> pool) 428var pool = _pool; 459private static readonly ObjectPool<ArrayBuilder<T>> s_poolInstance = CreatePool(); 487public static ObjectPool<ArrayBuilder<T>> CreatePool() 492public static ObjectPool<ArrayBuilder<T>> CreatePool(int size) 494ObjectPool<ArrayBuilder<T>>? pool = null;
src\Dependencies\PooledObjects\ObjectPool`1.cs (1)
122internal ObjectPool(Func<ObjectPool<T>, T> factory, int size)
src\Dependencies\PooledObjects\PooledDelegates.cs (1)
19public static readonly ObjectPool<T> Instance = new(() => new T(), 20);
src\Dependencies\PooledObjects\PooledDictionary.cs (5)
16private readonly ObjectPool<PooledDictionary<K, V>> _pool; 18private PooledDictionary(ObjectPool<PooledDictionary<K, V>> pool, IEqualityComparer<K> keyComparer) 40private static readonly ObjectPool<PooledDictionary<K, V>> s_poolInstance = CreatePool(EqualityComparer<K>.Default); 43public static ObjectPool<PooledDictionary<K, V>> CreatePool(IEqualityComparer<K> keyComparer) 45ObjectPool<PooledDictionary<K, V>>? pool = null;
src\Dependencies\PooledObjects\PooledHashSet.cs (5)
14private readonly ObjectPool<PooledHashSet<T>> _pool; 16private PooledHashSet(ObjectPool<PooledHashSet<T>> pool, IEqualityComparer<T> equalityComparer) : 29private static readonly ObjectPool<PooledHashSet<T>> s_poolInstance = CreatePool(EqualityComparer<T>.Default); 32public static ObjectPool<PooledHashSet<T>> CreatePool(IEqualityComparer<T> equalityComparer) 34ObjectPool<PooledHashSet<T>>? pool = null;
src\Dependencies\PooledObjects\PooledStringBuilder.cs (5)
21private readonly ObjectPool<PooledStringBuilder> _pool; 23private PooledStringBuilder(ObjectPool<PooledStringBuilder> pool) 73private static readonly ObjectPool<PooledStringBuilder> s_poolInstance = CreatePool(); 81public static ObjectPool<PooledStringBuilder> CreatePool(int size = 32) 83ObjectPool<PooledStringBuilder>? pool = null;
Syntax\SyntaxNavigator.cs (2)
92private static readonly ObjectPool<Stack<ChildSyntaxList.Enumerator>> s_childEnumeratorStackPool 138private static readonly ObjectPool<Stack<ChildSyntaxList.Reversed.Enumerator>> s_childReversedEnumeratorStackPool
Syntax\SyntaxNode.Iterators.cs (2)
47private static readonly ObjectPool<ChildSyntaxList.Enumerator[]> s_stackPool = new ObjectPool<ChildSyntaxList.Enumerator[]>(() => new ChildSyntaxList.Enumerator[16]); 133private static readonly ObjectPool<SyntaxTriviaList.Enumerator[]> s_stackPool = new ObjectPool<SyntaxTriviaList.Enumerator[]>(() => new SyntaxTriviaList.Enumerator[16]);
Syntax\SyntaxTriviaList.cs (1)
291private static readonly ObjectPool<SyntaxTriviaListBuilder> s_builderPool =
Text\CompositeText.cs (1)
363private static readonly ObjectPool<HashSet<SourceText>> s_uniqueSourcesPool
Text\SourceText.cs (2)
33private static readonly ObjectPool<char[]> s_charArrayPool = new ObjectPool<char[]>(() => new char[CharBufferSize], CharBufferCount); 34private static readonly ObjectPool<XxHash128> s_contentHashPool = new ObjectPool<XxHash128>(() => new XxHash128());