private StackDataMapping(LuaObjectPool luaObjectPool) { if (TypeTraits <T> .type == objType) { container = new Dictionary <T, int>(2017, new CompareObject()); } else { container = new Dictionary <T, int>(17); } luaObjectPool.AttachDisposeListenter(Clear); }
internal override void Destroy(LuaObjectPool objPool, int pos, bool bClean, bool bLogGC) { if (bClean) { RemoveMapping(objPool, pos); if (bLogGC) { Debugger.Log("destroy object {0}, id {1}", obj, pos); } } obj = default(T); }
private void RemoveMapping(LuaObjectPool objPool, int pos) { if (bObjectType) { if (obj != null) { StackDataMapping <object> .InstanceGet(objPool).Remove(obj, pos); } } else { StackDataMapping <T> .InstanceGet(objPool).Remove(obj, pos); } }
internal override int Remove(LuaObjectPool objPool, int pos, bool bLogGC) { RemoveMapping(objPool, pos); int result = head.index; head.index = pos; if (bLogGC) { Debugger.Log("gc object {0}, id {1}", obj, pos); } obj = default(T); return(result); }
public static StackDataMapping <T> InstanceGet(LuaObjectPool luaObjectPool) { #if !MULTI_STATE _instance = _instance ?? new StackDataMapping <T>(luaObjectPool); return(_instance); #else StackDataMapping <T> _instance = null; if (!_instanceGroup.TryGetValue(luaObjectPool, out _instance) || _instance == null) { _instance = new StackDataMapping <T>(luaObjectPool); _instanceGroup[luaObjectPool] = _instance; } return(_instance); #endif }
internal virtual void Destroy(LuaObjectPool objPool, int pos, bool bClean, bool bLogGC) { }
internal virtual int Remove(LuaObjectPool objPool, int pos, bool bLogGC) { return(-1); }