34 lines
855 B
C#
34 lines
855 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Framework
|
|
{
|
|
public partial class EventManager
|
|
{
|
|
private readonly List<Delegate> _tempExecuteList = new List<Delegate>(16);
|
|
private Stack<List<Delegate>> _tempExecutePool = new Stack<List<Delegate>>();
|
|
|
|
private int _eventStack = 0;
|
|
|
|
|
|
private List<Delegate> GetTempExecuteList()
|
|
{
|
|
if (_tempExecutePool.TryPop(out var list))
|
|
{
|
|
return list;
|
|
}
|
|
return new List<Delegate>(8);
|
|
}
|
|
|
|
private void ReCycleTempExecuteList(List<Delegate> list)
|
|
{
|
|
if (_tempExecutePool.Count < MAX_EVENT_STACK)
|
|
{
|
|
list.Clear();
|
|
_tempExecutePool.Push(list);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|