コード例 #1
0
ファイル: WorkerCoroutine.cs プロジェクト: stoddy2hotty/UMA
        public bool Work()
        {
            while (true)
            {
                // process nested work jobs first
                if (subWorker != null)
                {
                    if (subWorker.Work())
                    {
                        subWorker = null;
                    }
                    else
                    {
                        // subWorker requested pause
                        return false;
                    }
                }

                if (workerInstance == null)
                {
                    workerInstance = workerMethod();
                    Start();
                }

                bool done = !workerInstance.MoveNext(); // we're done when we can't get next Enumerator element
                if (done)
                {
                    // we truly are done
                    Stop();
                    workerInstance = null;
                    return true;
                }
                else
                {
                    subWorker = workerInstance.Current as WorkerCoroutine;
                    if (subWorker == null)
                    {
                        // returned null take a break
                        return false;
                    }

                    // returned a subWorker, no time to rest
                    continue;
                }
            }
        }
コード例 #2
0
        public bool Work()
        {
            TimeHint = 0;
            while (true)
            {
                // process nested work jobs first
                if (subWorker != null)
                {
                    if (subWorker.Work())
                    {
                        subWorker = null;
                    }
                    else
                    {
                        // subWorker requested pause
                        TimeHint = subWorker.TimeHint;
                        if (lastWorker == subWorker)
                        {
                            lastWorkerCount++;
                        }
                        else
                        {
                            lastWorkerCount = 1;
                        }
                        lastWorker = subWorker;
                        return(false);
                    }
                }

                if (workerInstance == null)
                {
                    workerInstance = workerMethod();
                    Start();
                }

                bool done;
                try
                {
                    done = !workerInstance.MoveNext(); // we're done when we can't get next Enumerator element
                }
                catch (Exception e)
                {
                    throw new Exception("Exception in WorkerCoroutine: " + this, e);
                }
                if (done)
                {
                    // we truly are done
                    Stop();
                    workerInstance = null;
                    return(true);
                }
                else
                {
                    subWorker = workerInstance.Current as WorkerCoroutine;
                    if (subWorker == null)
                    {
                        if (lastWorker == this)
                        {
                            lastWorkerCount++;
                        }
                        else
                        {
                            lastWorkerCount = 1;
                        }
                        lastWorker = this;

                        // returned null take a break
                        if (workerInstance.Current is int)
                        {
                            TimeHint = (int)workerInstance.Current;
                        }
                        return(false);
                    }

                    // returned a subWorker, no time to rest
                    continue;
                }
            }
        }
コード例 #3
0
 public void Cancel()
 {
     Stop();
     workerInstance = null;
     subWorker      = null;
 }
コード例 #4
0
ファイル: WorkerCoroutine.cs プロジェクト: CStudios15/UMA
		public bool Work()
	    {
            TimeHint = 0;
	        while (true)
	        {
	            // process nested work jobs first
	            if (subWorker != null)
	            {
	                if (subWorker.Work())
	                {
	                    subWorker = null;
	                }
	                else
	                {
	                    // subWorker requested pause
                        TimeHint = subWorker.TimeHint;
                        if (lastWorker == subWorker)
                        {
                            lastWorkerCount++;
                        }
                        else
                        {
                            lastWorkerCount = 1;
                        }
                        lastWorker = subWorker;
                        return false;
	                }
	            }

	            if (workerInstance == null)
	            {
	                workerInstance = workerMethod();
	                Start();
	            }

                bool done;
                try
                {
                    done = !workerInstance.MoveNext(); // we're done when we can't get next Enumerator element
                }
                catch(Exception e)
                {
                    throw new Exception("Exception in WorkerCoroutine: "+this, e);
                }
	            if (done)
	            {
	                // we truly are done
	                Stop();
	                workerInstance = null;
	                return true;
	            }
	            else
	            {
	                subWorker = workerInstance.Current as WorkerCoroutine;
	                if (subWorker == null)
	                {
                        if (lastWorker == this)
                        {
                            lastWorkerCount++;
                        }
                        else
                        {
                            lastWorkerCount = 1;
                        }
                        lastWorker = this;

                        // returned null take a break
                        if (workerInstance.Current is int)
                        {
                            TimeHint = (int)workerInstance.Current;
                        }
                        return false;
	                }

	                // returned a subWorker, no time to rest
	                continue;
	            }
	        }
	    }
コード例 #5
0
ファイル: WorkerCoroutine.cs プロジェクト: CStudios15/UMA
	    public void Cancel()
	    {
			Stop();
			workerInstance = null;
	        subWorker = null;
	    }