-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathConcurrentPool.cs
More file actions
30 lines (24 loc) · 901 Bytes
/
Copy pathConcurrentPool.cs
File metadata and controls
30 lines (24 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
namespace System.Collections.Pooling.Concurrent
{
public static partial class ConcurrentPool
{
public static IConcurrentPoolProvider Provider
=> _provider ?? _defaultProvider;
private static readonly DefaultProvider _defaultProvider;
private static IConcurrentPoolProvider _provider;
static ConcurrentPool()
{
_provider = _defaultProvider = new DefaultProvider();
}
public static void Set(IConcurrentPoolProvider provider)
=> _provider = provider ?? _defaultProvider;
public static void Set<T>() where T : IConcurrentPoolProvider, new()
=> _provider = new T();
public static T Get<T>() where T : IConcurrentPoolProviderDecorator, new()
{
var decorator = new T();
decorator.Set(Provider);
return decorator;
}
}
}