diff options
author | chai <chaifix@163.com> | 2021-01-25 14:28:30 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-01-25 14:28:30 +0800 |
commit | 6eb915c129fc90c6f4c82ae097dd6ffad5239efc (patch) | |
tree | 7dd2be50edf41f36b60fac84696e731c13afe617 /Client/Assets/Scripts/XUtliPoolLib/BufferPoolMgr.cs |
+scripts
Diffstat (limited to 'Client/Assets/Scripts/XUtliPoolLib/BufferPoolMgr.cs')
-rw-r--r-- | Client/Assets/Scripts/XUtliPoolLib/BufferPoolMgr.cs | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/Client/Assets/Scripts/XUtliPoolLib/BufferPoolMgr.cs b/Client/Assets/Scripts/XUtliPoolLib/BufferPoolMgr.cs new file mode 100644 index 00000000..b97e7f3c --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/BufferPoolMgr.cs @@ -0,0 +1,63 @@ +using System;
+
+namespace XUtliPoolLib
+{
+ public class BufferPoolMgr : XSingleton<BufferPoolMgr>
+ {
+ private SmallBufferPool<uint> m_UIntSmallBufferPool = new SmallBufferPool<uint>();
+
+ private SmallBufferPool<object> m_ObjSmallBufferPool = new SmallBufferPool<object>();
+
+ public static int TotalCount = 0;
+
+ public static int AllocSize = 0;
+
+ public BlockInfo[] uintBlockInit = new BlockInfo[]
+ {
+ new BlockInfo(4, 512),
+ new BlockInfo(8, 512),
+ new BlockInfo(16, 512),
+ new BlockInfo(32, 512),
+ new BlockInfo(64, 512),
+ new BlockInfo(256, 128),
+ new BlockInfo(512, 128)
+ };
+
+ public BlockInfo[] objBlockInit = new BlockInfo[]
+ {
+ new BlockInfo(8, 512),
+ new BlockInfo(16, 512),
+ new BlockInfo(32, 512),
+ new BlockInfo(64, 512),
+ new BlockInfo(256, 128),
+ new BlockInfo(512, 128)
+ };
+
+ public override bool Init()
+ {
+ this.m_UIntSmallBufferPool.Init(this.uintBlockInit, 4);
+ this.m_ObjSmallBufferPool.Init(this.objBlockInit, 4);
+ return true;
+ }
+
+ public void GetSmallBuffer(ref SmallBuffer<uint> sb, int size, int initSize = 0)
+ {
+ this.m_UIntSmallBufferPool.GetBlock(ref sb, size, 0);
+ }
+
+ public void ReturnSmallBuffer(ref SmallBuffer<uint> sb)
+ {
+ this.m_UIntSmallBufferPool.ReturnBlock(ref sb);
+ }
+
+ public void GetSmallBuffer(ref SmallBuffer<object> sb, int size, int initSize = 0)
+ {
+ this.m_ObjSmallBufferPool.GetBlock(ref sb, size, 0);
+ }
+
+ public void ReturnSmallBuffer(ref SmallBuffer<object> sb)
+ {
+ this.m_ObjSmallBufferPool.ReturnBlock(ref sb);
+ }
+ }
+}
|