示例#1
0
//----------------------------------------------------------------------------------------------------------------------

        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
//----------------------------------------------------------------------------------------------------------------------



        private static bool RequestLoadImageInternal(int imageType, BaseImageLoadBGTask imageLoadBGTask)
        {
            imageLoadBGTask.SetRequestFrame(GetCurrentFrame());

            if (null != m_imageLoadTaskHandler)
            {
                return(m_imageLoadTaskHandler(imageType, imageLoadBGTask));
            }

            ThreadManager.QueueBackGroundTask(imageLoadBGTask);
            return(true);
        }
示例#3
0
//----------------------------------------------------------------------------------------------------------------------

        private static bool RequestLoadImageInternal(int index, BaseImageLoadBGTask imageLoadBGTask)
        {
            imageLoadBGTask.SetRequestFrame(GetCurrentFrame());

#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                if (null == m_imageLoadEditorUpdateTasks[index])
                {
                    return(false);
                }
                return(m_imageLoadEditorUpdateTasks[index].RequestLoadImage(imageLoadBGTask));
            }
#endif


            ThreadManager.QueueBackGroundTask(imageLoadBGTask);
            return(true);
        }
示例#4
0
//----------------------------------------------------------------------------------------------------------------------
        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);
        }