From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- Client/Assets/Scripts/XMainClient/MobaInfoPool.cs | 39 +++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/MobaInfoPool.cs (limited to 'Client/Assets/Scripts/XMainClient/MobaInfoPool.cs') diff --git a/Client/Assets/Scripts/XMainClient/MobaInfoPool.cs b/Client/Assets/Scripts/XMainClient/MobaInfoPool.cs new file mode 100644 index 00000000..334241eb --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/MobaInfoPool.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; + +namespace XMainClient +{ + public class MobaInfoPool + { + private static Queue _pool; + + public static void Clear() + { + bool flag = MobaInfoPool._pool != null; + if (flag) + { + MobaInfoPool._pool.Clear(); + MobaInfoPool._pool = null; + } + } + + public static MobaReminder GetInfo() + { + bool flag = MobaInfoPool._pool == null; + if (flag) + { + MobaInfoPool._pool = new Queue(); + } + return (MobaInfoPool._pool.Count > 0) ? MobaInfoPool._pool.Dequeue() : new MobaReminder(); + } + + public static void Recycle(MobaReminder info) + { + bool flag = MobaInfoPool._pool == null; + if (!flag) + { + MobaInfoPool._pool.Enqueue(info); + } + } + } +} -- cgit v1.1-26-g67d0