void OnGUI()
    {
        GUILayout.Box("mCoroutinePool.HasTaskRuning: " + mCoroutinePool.HasCoroutineRuning);
        GUILayout.Box("Task Wait Queue Count: " + mCoroutinePool.CoroutineWaitQueueCount);
        GUILayout.Box("Runing Task Count: " + mCoroutinePool.GetRuningCoroutineCount());
        GUILayout.Box("Idle Task Count: " + mCoroutinePool.GetIdleCoroutineCount());
        GUILayout.Box("HasCoroutineIdle: " + mCoroutinePool.HasCoroutineIdle);
        GUILayout.Box("HasCoroutineRuning: " + mCoroutinePool.HasCoroutineRuning);

        if (GUILayout.Button("Execute New Virtual Light Task"))
        {
            var r = mCoroutinePool.StartCoroutine(VirtualLightTask());
            mCoroutineIDStack.Push(r.CoroutineID);
        }

        if (GUILayout.Button("Execute New Virtual Heavy Task"))
        {
            var r = mCoroutinePool.StartCoroutine(VirtualHeavyTask());
            mCoroutineIDStack.Push(r.CoroutineID);
        }

        if (GUILayout.Button("Execute New Virtual Heavy Task(Can`t interruption)"))
        {
            var r = mCoroutinePool.StartCoroutine(VirtualHeavyTask2());
            mCoroutineIDStack.Push(r.CoroutineID);
        }

        if (GUILayout.Button("Test Stop Task"))
        {
            if (mCoroutineIDStack.Count > 0)
            {
                var id = mCoroutineIDStack.Pop();
                mCoroutinePool.StopCoroutine(id);
            }
        }

        if (GUILayout.Button("Test Immediate Stop Task"))
        {
            if (mCoroutineIDStack.Count > 0)
            {
                var id = mCoroutineIDStack.Pop();
                mCoroutinePool.ImmediateStopCoroutine(id);
            }
        }
    }
예제 #2
0
        public void Unload()
        {
#if UNITY_EDITOR
            if (!EditorApplication.isPlaying)
            {
                UnloadInternalInEditMode();
                return;
            }
#endif
            CoroutinePool.StartCoroutine(UnloadInternalInPlayMode());
        }
예제 #3
0
 public static void Setup(CoroutinePool pool, IAsyncProcessor processor)
 {
     if (null == pool)
     {
         throw new ArgumentNullException("pool");
     }
     if (processor.IsSetup)
     {
         throw new AsyncRequestAlreadySetupException("Async processor cannot setup twice!");
     }
     processor.IsSetup      = true;
     processor.ThreadHandle = pool.StartCoroutine(ProcessAsync(processor));
     Logger.LogVerbose("Coroutine setup, processor: {0}, handle: {1}", processor, processor.ThreadHandle);
 }