blob: 6ba319f3205b1b19dbffde74d27fae677be0b2d8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
using System;
namespace XUtliPoolLib
{
public class CommonObjectPool<T> where T : new()
{
private static readonly ObjectPool<object> s_Pool = new ObjectPool<object>(new ObjectPool<object>.CreateObj(CommonObjectPool<T>.Create), null, null);
public static object Create()
{
return Activator.CreateInstance<T>();
}
public static T Get()
{
return (T)((object)CommonObjectPool<T>.s_Pool.Get());
}
public static void Release(T toRelease)
{
CommonObjectPool<T>.s_Pool.Release(toRelease);
}
}
}
|