13 instantiations of ObjectPool
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost (13)
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (1)
94var pool = new ObjectPool<StringTable>(pool => new StringTable(pool), Environment.ProcessorCount * 2);
src\Compilers\Core\Portable\InternalUtilities\TextKeyedCache.cs (1)
86var pool = new ObjectPool<TextKeyedCache<T>>(
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);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\ObjectPools\SharedPools.cs (6)
44new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase), 20); 50new(() => new HashSet<string>(StringComparer.Ordinal), 20); 56public static readonly ObjectPool<byte[]> ByteArray = new(() => new byte[ByteBufferSize], ByteBufferCount); 64public static readonly ObjectPool<T> Instance = new(() => new T(), 100); 69public static readonly ObjectPool<T> Instance = new(() => new T(), 20); 75new(() => new Dictionary<string, T>(StringComparer.OrdinalIgnoreCase), 20);
107 references to ObjectPool
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost (107)
src\Compilers\Core\Portable\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);
src\Compilers\Core\Portable\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>>(
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;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\ObjectPools\Extensions.cs (35)
18public static PooledObject<StringBuilder> GetPooledObject(this ObjectPool<StringBuilder> pool) 21public static PooledObject<StringBuilder> GetPooledObject(this ObjectPool<StringBuilder> pool, out StringBuilder builder) 28public static PooledObject<Stack<TItem>> GetPooledObject<TItem>(this ObjectPool<Stack<TItem>> pool) 31public static PooledObject<Queue<TItem>> GetPooledObject<TItem>(this ObjectPool<Queue<TItem>> pool) 34public static PooledObject<HashSet<TItem>> GetPooledObject<TItem>(this ObjectPool<HashSet<TItem>> pool) 37public static PooledObject<Dictionary<TKey, TValue>> GetPooledObject<TKey, TValue>(this ObjectPool<Dictionary<TKey, TValue>> pool) where TKey : notnull 40public static PooledObject<List<TItem>> GetPooledObject<TItem>(this ObjectPool<List<TItem>> pool) 43public static PooledObject<SegmentedList<TItem>> GetPooledObject<TItem>(this ObjectPool<SegmentedList<TItem>> pool) 46public static PooledObject<Stack<TItem>> GetPooledObject<TItem>(this ObjectPool<Stack<TItem>> pool, out Stack<TItem> stack) 53public static PooledObject<List<TItem>> GetPooledObject<TItem>(this ObjectPool<List<TItem>> pool, out List<TItem> list) 60public static PooledObject<SegmentedList<TItem>> GetPooledObject<TItem>(this ObjectPool<SegmentedList<TItem>> pool, out SegmentedList<TItem> list) 67public static PooledObject<HashSet<TItem>> GetPooledObject<TItem>(this ObjectPool<HashSet<TItem>> pool, out HashSet<TItem> set) 74public static PooledObject<Dictionary<TKey, TValue>> GetPooledObject<TKey, TValue>(this ObjectPool<Dictionary<TKey, TValue>> pool, out Dictionary<TKey, TValue> dictionary) 82public static PooledObject<ConcurrentSet<T>> GetPooledObject<T>(this ObjectPool<ConcurrentSet<T>> pool, out ConcurrentSet<T> set) 90public static PooledObject<T> GetPooledObject<T>(this ObjectPool<T> pool) where T : class 93public static StringBuilder AllocateAndClear(this ObjectPool<StringBuilder> pool) 101public static Stack<T> AllocateAndClear<T>(this ObjectPool<Stack<T>> pool) 109public static Queue<T> AllocateAndClear<T>(this ObjectPool<Queue<T>> pool) 117public static HashSet<T> AllocateAndClear<T>(this ObjectPool<HashSet<T>> pool) 125public static ConcurrentSet<T> AllocateAndClear<T>(this ObjectPool<ConcurrentSet<T>> pool) where T : notnull 133public static SegmentedHashSet<T> AllocateAndClear<T>(this ObjectPool<SegmentedHashSet<T>> pool) 141public static Dictionary<TKey, TValue> AllocateAndClear<TKey, TValue>(this ObjectPool<Dictionary<TKey, TValue>> pool) 150public static List<T> AllocateAndClear<T>(this ObjectPool<List<T>> pool) 158public static SegmentedList<T> AllocateAndClear<T>(this ObjectPool<SegmentedList<T>> pool) 166public static void ClearAndFree(this ObjectPool<StringBuilder> pool, StringBuilder sb) 183public static void ClearAndFree<T>(this ObjectPool<HashSet<T>> pool, HashSet<T> set) 201public static void ClearAndFree<T>(this ObjectPool<SegmentedHashSet<T>> pool, SegmentedHashSet<T> set) 219public static void ClearAndFree<T>(this ObjectPool<ConcurrentSet<T>> pool, ConcurrentSet<T> set) where T : notnull 235public static void ClearAndFree<T>(this ObjectPool<Stack<T>> pool, Stack<T> stack) 249public static void ClearAndFree<T>(this ObjectPool<ConcurrentStack<T>> pool, ConcurrentStack<T> stack) 265public static void ClearAndFree<T>(this ObjectPool<Queue<T>> pool, Queue<T> set) 283public static void ClearAndFree<TKey, TValue>(this ObjectPool<Dictionary<TKey, TValue>> pool, Dictionary<TKey, TValue> map) 302public static void ClearAndFree<TKey, TValue>(this ObjectPool<ConcurrentDictionary<TKey, TValue>> pool, ConcurrentDictionary<TKey, TValue> map) 319public static void ClearAndFree<T>(this ObjectPool<List<T>> pool, List<T> list, bool trim = true) 336public static void ClearAndFree<T>(this ObjectPool<SegmentedList<T>> pool, SegmentedList<T> list, bool trim = true)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\ObjectPools\PooledObject.cs (29)
19private readonly Action<ObjectPool<T>, T> _releaser; 20private readonly ObjectPool<T> _pool; 22public PooledObject(ObjectPool<T> pool, Func<ObjectPool<T>, T> allocator, Action<ObjectPool<T>, T> releaser) : this() 41public static PooledObject<StringBuilder> Create(ObjectPool<StringBuilder> pool) 49public static PooledObject<Stack<TItem>> Create<TItem>(ObjectPool<Stack<TItem>> pool) 57public static PooledObject<Queue<TItem>> Create<TItem>(ObjectPool<Queue<TItem>> pool) 65public static PooledObject<HashSet<TItem>> Create<TItem>(ObjectPool<HashSet<TItem>> pool) 73public static PooledObject<ConcurrentSet<TItem>> Create<TItem>(ObjectPool<ConcurrentSet<TItem>> pool) where TItem : notnull 81public static PooledObject<Dictionary<TKey, TValue>> Create<TKey, TValue>(ObjectPool<Dictionary<TKey, TValue>> pool) 90public static PooledObject<List<TItem>> Create<TItem>(ObjectPool<List<TItem>> pool) 98public static PooledObject<SegmentedList<TItem>> Create<TItem>(ObjectPool<SegmentedList<TItem>> pool) 109private static StringBuilder Allocator(ObjectPool<StringBuilder> pool) 112private static void Releaser(ObjectPool<StringBuilder> pool, StringBuilder sb) 115private static Stack<TItem> Allocator<TItem>(ObjectPool<Stack<TItem>> pool) 118private static void Releaser<TItem>(ObjectPool<Stack<TItem>> pool, Stack<TItem> obj) 121private static Queue<TItem> Allocator<TItem>(ObjectPool<Queue<TItem>> pool) 124private static void Releaser<TItem>(ObjectPool<Queue<TItem>> pool, Queue<TItem> obj) 127private static HashSet<TItem> Allocator<TItem>(ObjectPool<HashSet<TItem>> pool) 130private static ConcurrentSet<TItem> Allocator<TItem>(ObjectPool<ConcurrentSet<TItem>> pool) where TItem : notnull 133private static void Releaser<TItem>(ObjectPool<HashSet<TItem>> pool, HashSet<TItem> obj) 136private static void Releaser<TItem>(ObjectPool<ConcurrentSet<TItem>> pool, ConcurrentSet<TItem> obj) where TItem : notnull 139private static Dictionary<TKey, TValue> Allocator<TKey, TValue>(ObjectPool<Dictionary<TKey, TValue>> pool) 143private static void Releaser<TKey, TValue>(ObjectPool<Dictionary<TKey, TValue>> pool, Dictionary<TKey, TValue> obj) 147private static List<TItem> Allocator<TItem>(ObjectPool<List<TItem>> pool) 150private static void Releaser<TItem>(ObjectPool<List<TItem>> pool, List<TItem> obj) 153private static SegmentedList<TItem> Allocator<TItem>(ObjectPool<SegmentedList<TItem>> pool) 156private static void Releaser<TItem>(ObjectPool<SegmentedList<TItem>> pool, SegmentedList<TItem> obj)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\ObjectPools\SharedPools.cs (9)
25public static ObjectPool<T> BigDefault<T>() where T : class, new() 31public static ObjectPool<T> Default<T>() where T : class, new() 37public static ObjectPool<Dictionary<string, T>> StringIgnoreCaseDictionary<T>() 43public static readonly ObjectPool<HashSet<string>> StringIgnoreCaseHashSet = 49public static readonly ObjectPool<HashSet<string>> StringHashSet = 56public static readonly ObjectPool<byte[]> ByteArray = new(() => new byte[ByteBufferSize], ByteBufferCount); 64public static readonly ObjectPool<T> Instance = new(() => new T(), 100); 69public static readonly ObjectPool<T> Instance = new(() => new T(), 20); 74public static readonly ObjectPool<Dictionary<string, T>> Instance =