Exemple #1
0
        private static T Acquire <T>(ObjectPoolKey data, object param) where T : class, IPoolObject
        {
            Type typeFromHandle = typeof(T);
            IObjectPoolContainer objectPoolContainer = ObjectPoolManager.I_GetObjectPoolContainer(data);

            TsLog.Assert(objectPoolContainer != null, "ObjectPoolConatiner is not found for {0} class.", new object[]
            {
                typeFromHandle.Name
            });
            T t = (T)((object)null);

            if (objectPoolContainer == null)
            {
                TsLog.Assert(false, "ObjectPoolManager. Class {0} poolContainer is null", new object[]
                {
                    typeFromHandle.Name
                });
            }
            else if (objectPoolContainer.objectPoolAttr == null)
            {
                TsLog.Assert(false, "ObjectPoolManager. ObjectPoolAttribute for class {0} is null", new object[]
                {
                    typeFromHandle.Name
                });
            }
            else if (objectPoolContainer.objectPoolAttr.CreateObjectStaticPrivate == null)
            {
                TsLog.Assert(false, "{0} class ObjectPoolAttribute.CreateInstance is not found!", new object[]
                {
                    typeFromHandle.Name
                });
            }
            else
            {
                t = (objectPoolContainer.Acquire() as T);
                if (t == null)
                {
                    TsLog.LogError("ObjectPoolManager.Acquire<T>(). Fail creation {0}.", new object[]
                    {
                        typeFromHandle.Name
                    });
                }
                else
                {
                    t.OnCreate(param);
                }
            }
            return(t);
        }
Exemple #2
0
            public void OnCompleteDonwload(WWWItem wItem, object wwwdownload)
            {
                object mainAsset = wItem.mainAsset;

                if (mainAsset == null)
                {
                    TsLog.LogWarning("WWW.mainAsset casting error. {0}", new object[]
                    {
                        wItem.assetPath
                    });
                }
                else
                {
                    ResourceCache.LifeSaver value = new ResourceCache.LifeSaver(mainAsset);
                    ResourceCache.WWWDownloader.ms_refCacheDic.Add(wItem.assetPath, value);
                    this.callback(wItem, this.param);
                }
                ResourceCache.WWWDownloader tobj = wwwdownload as ResourceCache.WWWDownloader;
                ObjectPoolManager.Release <ResourceCache.WWWDownloader>(tobj);
            }
Exemple #3
0
 public static void Release <T>(T tobj) where T : class, IPoolObject
 {
     ObjectPoolManager.Release <T>(tobj, new ObjectPoolKey(typeof(T)));
 }
Exemple #4
0
        public static T Acquire <T>(int size, object param) where T : class, IPoolObject
        {
            ObjectPoolKey data = new ObjectPoolKey(typeof(T), size);

            return(ObjectPoolManager.Acquire <T>(data, param));
        }
Exemple #5
0
        public static T Acquire <T>() where T : class, IPoolObject
        {
            ObjectPoolKey data = new ObjectPoolKey(typeof(T));

            return(ObjectPoolManager.Acquire <T>(data, null));
        }