public void Run(FogOfWarThreadTask task)
        {
            // add to any waiting threads
            for (int i = maxThreads; i < _threads.Count; ++i)
            {
                if (_threads[i].state == FogOfWarThreadState.Running && _threads[i].isWaiting)
                {
                    _threads[i].Run(task);
                    return;
                }
            }

            // create thread
            if (_threads.Count < maxThreads)
            {
                FogOfWarThread newthread = new FogOfWarThread(this);
                _threads.Add(newthread);
                newthread.Run(task);
                return;
            }

            // no available threads, so just add it to the queue
            lock (_taskQueue)
                _taskQueue.Add(task);
        }
 internal FogOfWarThreadTask RequestNewTask(FogOfWarThread thread)
 {
     lock (_taskQueue)
     {
         if (_taskQueue.Count > 0)
         {
             FogOfWarThreadTask newtask = _taskQueue[_taskQueue.Count - 1];
             _taskQueue.RemoveAt(_taskQueue.Count - 1);
             return(newtask);
         }
     }
     return(null);
 }
Exemplo n.º 3
0
 internal System.Action RequestNewAction(FogOfWarThread thread)
 {
     lock (_actionQueue)
     {
         if (_actionQueue.Count > 0)
         {
             System.Action newaction = _actionQueue[_actionQueue.Count - 1];
             _actionQueue.RemoveAt(_actionQueue.Count - 1);
             return(newaction);
         }
     }
     return(null);
 }