示例#1
0
    public static void ReleaseObject <T>(HeapObjectBase obj)
    {
        string type = typeof(T).Name;

        JudgeNullPool(type);

        s_pool[type].Add(obj);
    }
示例#2
0
    public static void Init(string type, int count = 20)
    {
        JudgeNullPool(type);

        List <HeapObjectBase> list = s_pool[type];

        for (int i = 0; i < count; i++)
        {
            Type t = Type.GetType(type);

            HeapObjectBase tmp = (HeapObjectBase)Activator.CreateInstance(t);
            list.Add(tmp);
        }
    }
 static int Release(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         HeapObjectBase obj = (HeapObjectBase)ToLua.CheckObject(L, 1, typeof(HeapObjectBase));
         obj.Release();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
示例#4
0
    public static T GetObject <T>(string TypeName) where T : HeapObjectBase, new()
    {
        JudgeNullPool(TypeName);

        List <HeapObjectBase> list = s_pool[TypeName];

        if (list.Count > 0)
        {
            HeapObjectBase tmp = list[0];
            list.RemoveAt(0);

            return((T)tmp);
        }
        else
        {
            Init <T>();
            return(GetObject <T>());
        }
    }
示例#5
0
    public static HeapObjectBase GetObject(string type)
    {
        JudgeNullPool(type);

        List <HeapObjectBase> list = s_pool[type];

        if (list.Count > 0)
        {
            HeapObjectBase tmp = list[0];
            list.RemoveAt(0);

            return(tmp);
        }
        else
        {
            Init(type);
            return(GetObject(type));
        }
    }
示例#6
0
    public static T GetObject <T>() where T : HeapObjectBase, new()
    {
        string type = typeof(T).Name;

        JudgeNullPool(type);

        List <HeapObjectBase> list = s_pool[type];

        if (list.Count > 0)
        {
            HeapObjectBase tmp = list[0];
            list.RemoveAt(0);

            return((T)tmp);
        }
        else
        {
            Init <T>();
            return(GetObject <T>());
        }
    }
    static int _CreateHeapObjectBase(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 0)
            {
                HeapObjectBase obj = new HeapObjectBase();
                ToLua.PushObject(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: HeapObjectBase.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
示例#8
0
    public static void ReleaseObject(string type, HeapObjectBase obj)
    {
        JudgeNullPool(type);

        s_pool[type].Add(obj);
    }