forked from laicasaane/unity-supplements
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPool.cs
More file actions
30 lines (24 loc) · 820 Bytes
/
Pool.cs
File metadata and controls
30 lines (24 loc) · 820 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
{
public static partial class Pool
{
public static IPoolProvider Provider
=> _provider ?? _defaultProvider;
private static readonly DefaultProvider _defaultProvider;
private static IPoolProvider _provider;
static Pool()
{
_provider = _defaultProvider = new DefaultProvider();
}
public static void Set(IPoolProvider provider)
=> _provider = provider ?? _defaultProvider;
public static void Set<T>() where T : IPoolProvider, new()
=> _provider = new T();
public static T Get<T>() where T : IPoolProviderDecorator, new()
{
var decorator = new T();
decorator.Set(Provider);
return decorator;
}
}
}