123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- using System;
- using System.Collections.Generic;
- using Fort23.Core;
- namespace Core.Utility.Event
- {
- public class EventDataBasic<T> : IEventData ,IDisposable where T : class, new()
- {
- private static readonly Queue<T> queue = new Queue<T>();
- public bool isHuiShou;
-
- public void Recycle()
- {
- Dispose();
- }
- public static T Create()
- {
- if (queue.Count <= 0)
- {
- T t = new T();
- return t;
- }
- T VALUE = queue.Dequeue();
- // System.GC.ReRegisterForFinalize(VALUE);
- return VALUE;
- }
- public static void Recycle(T data)
- {
- if (data == null || queue.Contains(data))
- {
- return;
- }
- if (queue.Count > 10)
- {
- return;
- }
- // System.GC.SuppressFinalize(data);
- queue.Enqueue(data);
- }
- protected EventDataBasic()
- {
- }
- public void Dispose()
- {
- ProDispose();
- Recycle(this as T);
- }
- protected virtual void ProDispose()
- {
-
- }
- }
- }
|