//----------------------------------------------------------------------------------------------------------------------

        internal bool RequestLoadImage(BaseImageLoadBGTask task)
        {
            //Clear old tasks
            int taskRequestFrame = task.GetRequestFrame();

            if (taskRequestFrame > m_latestFrame)
            {
                m_latestFrame = taskRequestFrame;
                m_requestedImageLoadBGTasks.Clear();
                m_taskHashSet.Clear();
            }


            const int MAX_PENDING_REQUESTS = 32;

            if (m_requestedImageLoadBGTasks.Count >= MAX_PENDING_REQUESTS)
            {
                return(false);
            }

            string imagePath = task.GetImagePath();

            if (m_taskHashSet.Contains(imagePath))
            {
                return(true);
            }

            m_requestedImageLoadBGTasks.Enqueue(task);
            m_taskHashSet.Add(imagePath);

            return(true);
        }
示例#2
0
        static bool RequestLoadImageInEditMode(int imageType, BaseImageLoadBGTask task)
        {
            Assert.IsFalse(Application.isPlaying);

            if (null == m_imageLoadEditorUpdateTasks[imageType])
            {
                return(false);
            }
            return(m_imageLoadEditorUpdateTasks[imageType].RequestLoadImage(task));
        }
//----------------------------------------------------------------------------------------------------------------------
        public void Execute()
        {
            if (m_requestedImageLoadBGTasks.Count <= 0)
            {
                return;
            }

            //Don't push everything to ThreadManager
            const int MAX_BACKGROUND_TASKS = 16;
            int       numBackGroundTasks   = ThreadManager.GetNumBackGroundTasks();

            if (numBackGroundTasks >= MAX_BACKGROUND_TASKS)
            {
                return;
            }

            BaseImageLoadBGTask task = m_requestedImageLoadBGTasks.Dequeue();

            m_taskHashSet.Remove(task.GetImagePath());

            ThreadManager.QueueBackGroundTask(task);
        }