Esempio n. 1
0
        //int tasksDoneThisFrame = 0;
        void Update()
        {
            long startedTime = iSCDTimeUtilities.MillisecondsSinceJanFirst1970();
            long maxTimeCost = (long)(1f / targetedFramerate * 100f);

            long lastestStopTime = startedTime + maxTimeCost;

            lock (registeredTasks) {
                while (lastestStopTime > iSCDTimeUtilities.MillisecondsSinceJanFirst1970())
                {
                    //Debug.Log ("s" + iSCDTimeUtilities.MillisecondsSinceJanFirst1970 ().ToString() + "t" + lastestStopTime);
                    if (registeredTasks.Count <= 0)
                    {
                        break;
                    }

                    TaskInformationPackage package = registeredTasks [0];

                    try{
                        if (package.task != null)
                        {
                            package.task();
                        }
                        if (package.finishCallback != null)
                        {
                            package.finishCallback();
                        }
                        if (package.taskFinishCallback != null)
                        {
                            package.taskFinishCallback(package.callerThreadID);
                        }
                    }
                    catch (Exception e) {
                        Debug.LogError("iSCDRuntime: Uncatched exception raised in main thread queue, aborting thread " + package.callerThreadID.ToString());
                        Debug.LogError("Exception: " + e.ToString());
                        AbortThread(package.callerThreadID);
                    }
                    finally{
                        registeredTasks.RemoveAt(0);
                        //tasksDoneThisFrame++;
                    }
                }
            }
            //Debug.Log (tasksDoneThisFrame);
            //tasksDoneThisFrame = 0;
        }