From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Scripts/XUtliPoolLib/CommonObjectPool.cs | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Client/Assets/Scripts/XUtliPoolLib/CommonObjectPool.cs (limited to 'Client/Assets/Scripts/XUtliPoolLib/CommonObjectPool.cs') diff --git a/Client/Assets/Scripts/XUtliPoolLib/CommonObjectPool.cs b/Client/Assets/Scripts/XUtliPoolLib/CommonObjectPool.cs new file mode 100644 index 00000000..6ba319f3 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/CommonObjectPool.cs @@ -0,0 +1,24 @@ +using System; + +namespace XUtliPoolLib +{ + public class CommonObjectPool where T : new() + { + private static readonly ObjectPool s_Pool = new ObjectPool(new ObjectPool.CreateObj(CommonObjectPool.Create), null, null); + + public static object Create() + { + return Activator.CreateInstance(); + } + + public static T Get() + { + return (T)((object)CommonObjectPool.s_Pool.Get()); + } + + public static void Release(T toRelease) + { + CommonObjectPool.s_Pool.Release(toRelease); + } + } +} -- cgit v1.1-26-g67d0