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