Exemplo n.º 1
0
    public void onTick(int count)
    {
        if (loadQueue.Count <= 0)
        {
            return;
        }
        LoaderTask task = loadQueue.Peek();

        if (task.status == E_LoadStatus.Loading)
        {
            return;
        }
        if (task.status == E_LoadStatus.Finish || task.status == E_LoadStatus.Fail)
        {
            removeTask(task.url);
            loadQueue.Dequeue();
            if (loadQueue.Count > 0)
            {
                task = loadQueue.Peek();
            }
        }
        if (task != null && task.status == E_LoadStatus.Wait)
        {
            task.doLoad();
        }
    }
Exemplo n.º 2
0
 public void InsertTask(LoaderTask task)
 {
     currentLoaderTask = task;
     reponseData       = null;
     state             = State.Busy;
     currentTask       = new SimpleTask(request());
 }
Exemplo n.º 3
0
    private void add(string url, Action <string, bool, TBundle> call = null)
    {
        LoaderTask task = new LoaderTask(url, call);

        dictTask.Add(task.url, task);
        loadQueue.Enqueue(task);
    }
Exemplo n.º 4
0
    void Update()
    {
        if (taskList.Count == 0)
        {
            return;
        }

        while (true)
        {
            LoaderItem loader = GetIdleLoaderItem();
            if (loader == null)
            {//没有空闲loader
                break;
            }

            int taskindex = GetLoaderTaskIndex();
            if (taskindex < 0)
            {//没有需要轮询的请求
                return;
            }

            LoaderTask lt = taskList[taskindex];
            taskList.RemoveAt(taskindex);
            loader.InsertTask(lt);
        }
    }
Exemplo n.º 5
0
    void LoadFinish(LoaderItem loader)
    {
        //return;//不使用相同url同一返回出力,因为可能有postdata请求
        #region  相同的请求 统一执行回调

        if (loader.currentLoaderTask == null)
        {
            return;
        }

        List <LoaderTask> tasks = taskList.FindAll((LoaderTask t) =>
        {
            LoaderTask tk = loader.currentLoaderTask;
            return(t.url == tk.url &&
                   t.type == tk.type &&
                   t.postdata == tk.postdata);
        });

        if (tasks != null && tasks.Count > 0)
        {
            int length = tasks.Count;
            for (int i = 0; i < length; i++)
            {
                LoaderTask lt = tasks[i];
                lt.SetResponseData(loader.reponseData);
                taskList.Remove(tasks[i]);
            }
        }
        #endregion
    }
Exemplo n.º 6
0
        public static LoaderGroup Get(LoaderTask loaderTask)
        {
            LoaderGroup loaderGroup = s_LoaderGroupPool.Get();

            loaderGroup.loaderTask = loaderTask;
            return(loaderGroup);
        }
Exemplo n.º 7
0
    int GetLoaderTaskIndex()
    {
        int index  = -1;
        int length = taskList.Count;

        for (int i = 0; i < length; i++)
        {
            LoaderTask lt = taskList[i];

            bool exsitSame = loaderitemList.Exists((LoaderItem li) =>
            {
                return(!li.isIdle &&
                       li.currentLoaderTask != null &&
                       li.currentLoaderTask.url == lt.url &&
                       li.currentLoaderTask.type == lt.type &&
                       li.currentLoaderTask.postdata == lt.postdata);
            });
            if (exsitSame)
            {
                continue;
            }
            else
            {
                index = i;
                break;
            }
        }
        return(index);
    }
Exemplo n.º 8
0
    protected override LoaderTask IniTask(LoaderContianer contianer)
    {
        LoaderTask task = null;

        if (local)
        {
            task = new LoaderTask(contianer, LoadType.LocalAB, name);
        }
        else
        {
            task = new LoaderTask(contianer, OutUri(name), null, header);
        }

        return(task);
    }
Exemplo n.º 9
0
        public Loader(ParameterConfiguration config, LoaderTask task)
        {
            List <FileInfo> filelist = null;

            this.config = config;
            this.task   = task;

            if (task == LoaderTask.LoaderTaskBoogie)
            {
                if ((config.preludeBplFileInfo == null) || (!config.preludeBplFileInfo.Exists))
                {
                    throw new Exception("Cannot load VCC prelude file.");
                }
                if ((config.codeBplFileInfo == null) || (!config.codeBplFileInfo.Exists))
                {
                    throw new Exception("Cannot load Boogie specification.");
                }
                filelist = new List <FileInfo> {
                    config.preludeBplFileInfo, config.codeBplFileInfo
                };
            }
            else
            {
                filelist = new List <FileInfo>();
                if (config.preludeBplFileInfo != null)
                {
                    if (!config.preludeBplFileInfo.Exists)
                    {
                        throw new Exception("Cannot load VCC prelude file.");
                    }
                    filelist.Add(config.preludeBplFileInfo);
                }

                if (config.codeBplFileInfo != null)
                {
                    if (!config.codeBplFileInfo.Exists)
                    {
                        throw new Exception("Cannot load Boogie specification.");
                    }
                    filelist.Add(config.codeBplFileInfo);
                }
            }
            processor = new LogProcessor(filelist, config.skipDecisions, config.checkToConsider);
        }
Exemplo n.º 10
0
    public void DeleteTask(LoaderTask task)
    {
        if (taskList.Contains(task))
        {
            taskList.Remove(task);
        }
        else
        {
            LoaderItem item = loaderitemList.Find((LoaderItem _loader) =>
            {
                return(!_loader.isIdle &&
                       _loader.currentLoaderTask == task);
            });

            if (item != null)
            {
                item.Dispose();
            }
        }
    }
Exemplo n.º 11
0
        public ResourceManager()
        {
            if (ConstantData.enableCache)
            {
                Caching.compressionEnabled = false;

                string path = ConstantData.unpackPath;
                FileUtil.CreateDirectory(path);

                UnityEngine.Cache cache = Caching.GetCacheByPath(path);
                if (!cache.valid)
                {
                    cache = Caching.AddCache(path);
                }

                Caching.currentCacheForWriting = cache;
            }
            else
            {
                if (ConstantData.enablePatch)
                {
                    AddSearchPath(ConstantData.patchPath);
                }

                if (ConstantData.enableCustomCompress)
                {
                    AddSearchPath(ConstantData.unpackPath);
                }
            }

            m_task            = new LoaderTask();
            m_cache           = new AssetBundleCache(m_task);
            m_downloadOrCache = new DownloadOrCache();

            Clear();

            if (ConstantData.enableAssetBundle)
            {
                LoadVersion();
            }
        }
Exemplo n.º 12
0
    void LoadFinish(LoaderItem loader)
    {
        #region  相同的请求 统一执行回调

        List <LoaderTask> tasks = taskList.FindAll((LoaderTask t) =>
        {
            LoaderTask tk = loader.currentLoaderTask;
            return(t.url == tk.url &&
                   t.type == tk.type);
        });

        if (tasks != null)
        {
            for (int i = 0; i < tasks.Count; i++)
            {
                LoaderTask lt = tasks[i];
                lt.SetResponseData(loader.reponseData);
                taskList.Remove(tasks[i]);
            }
        }
        #endregion
    }
Exemplo n.º 13
0
 public void addTask(string url, Action <string, bool, TBundle> call)
 {
     if (!dictTask.ContainsKey(url))
     {
         List <string> depends = new List <string>();
         ManifestMgr.getDepends(url, ref depends);
         //先加载所有依赖
         for (int i = 0; i < depends.Count; i++)
         {
             if (depends[i].EndsWith(".assetbundle"))
             {
                 depends[i] = depends[i].Replace(".assetbundle", "");
             }
             addTask(depends[i], null);
         }
         LoaderTask task = new LoaderTask(url, call);
         dictTask.Add(task.url, task);
     }
     else
     {
         dictTask[url].addHandler(call);
     }
 }
Exemplo n.º 14
0
    protected override LoaderTask IniTask(LoaderContianer contianer)
    {
        LoaderTask task = new LoaderTask(contianer, LoadType.LocalAB, url);

        return(task);
    }
Exemplo n.º 15
0
    protected override LoaderTask IniTask(LoaderContianer contianer)
    {
        LoaderTask task = new LoaderTask(contianer, path, null, new System.Collections.Generic.Dictionary <string, string>());

        return(task);
    }
Exemplo n.º 16
0
 public void InsertTask(LoaderTask task)
 {
     taskList.Add(task);
 }
Exemplo n.º 17
0
 public void Connect()
 {
     task = IniTask(contianer);
     task.AddListener(LoadComplete);
     task.Start();
 }
Exemplo n.º 18
0
    protected override LoaderTask IniTask(LoaderContianer contianer)
    {
        LoaderTask task = new LoaderTask(contianer, OutUri(name), null, header);

        return(task);
    }
    protected override LoaderTask IniTask(LoaderContianer contianer)
    {
        LoaderTask task = new LoaderTask(contianer, LoadType.StreamAssets, url);

        return(task);
    }
    protected override LoaderTask IniTask(LoaderContianer contianer)
    {
        LoaderTask task = new LoaderTask(contianer, LoadType.Get, GetLocalServer());

        return(task);
    }