示例#1
0
        internal PathProcessor(AstarPath astar, PathReturnQueue returnQueue, int processors, bool multithreaded)
        {
            this.astar       = astar;
            this.returnQueue = returnQueue;

            if (processors < 0)
            {
                throw new System.ArgumentOutOfRangeException("processors");
            }

            if (!multithreaded && processors != 1)
            {
                throw new System.Exception("Only a single non-multithreaded processor is allowed");
            }

            // Set up path queue with the specified number of receivers
            queue        = new ThreadControlQueue(processors);
            pathHandlers = new PathHandler[processors];

            for (int i = 0; i < processors; i++)
            {
                pathHandlers[i] = new PathHandler(i, processors);
            }

            if (multithreaded)
            {
                threads = new Thread[processors];

                // Start lots of threads
                for (int i = 0; i < processors; i++)
                {
                    var pathHandler = pathHandlers[i];
                    threads[i]              = new Thread(() => CalculatePathsThreaded(pathHandler));
                    threads[i].Name         = "Pathfinding Thread " + i;
                    threads[i].IsBackground = true;
                    threads[i].Start();
                }
            }
            else
            {
                // Start coroutine if not using multithreading
                threadCoroutine = CalculatePaths(pathHandlers[0]);
            }
        }
示例#2
0
		public PathProcessor(AstarPath astar, PathReturnQueue returnQueue, int processors, bool multithreaded)
		{
			this.astar = astar;
			this.returnQueue = returnQueue;
			if (processors < 0)
			{
				throw new ArgumentOutOfRangeException("processors");
			}
			if (!multithreaded && processors != 1)
			{
				throw new Exception("Only a single non-multithreaded processor is allowed");
			}
			this.queue = new ThreadControlQueue(processors);
			this.threadInfos = new PathThreadInfo[processors];
			for (int i = 0; i < processors; i++)
			{
				this.threadInfos[i] = new PathThreadInfo(i, astar, new PathHandler(i, processors));
			}
			if (multithreaded)
			{
				this.threads = new Thread[processors];
				for (int j = 0; j < processors; j++)
				{
					int threadIndex = j;
					Thread thread = new Thread(delegate
					{
						this.CalculatePathsThreaded(this.threadInfos[threadIndex]);
					});
					thread.Name = "Pathfinding Thread " + j;
					thread.IsBackground = true;
					this.threads[j] = thread;
					thread.Start();
				}
			}
			else
			{
				this.threadCoroutine = this.CalculatePaths(this.threadInfos[0]);
			}
		}
示例#3
0
 public PathProcessor(AstarPath astar, PathReturnQueue returnQueue, int processors, bool multithreaded)
 {
     this.astar       = astar;
     this.returnQueue = returnQueue;
     if (processors < 0)
     {
         throw new ArgumentOutOfRangeException("processors");
     }
     if (!multithreaded && (processors != 1))
     {
         throw new Exception("Only a single non-multithreaded processor is allowed");
     }
     this.queue       = new ThreadControlQueue(processors);
     this.threadInfos = new PathThreadInfo[processors];
     for (int i = 0; i < processors; i++)
     {
         this.threadInfos[i] = new PathThreadInfo(i, astar, new PathHandler(i, processors));
     }
     if (multithreaded)
     {
         this.threads = new Thread[processors];
         for (int j = 0; j < processors; j++)
         {
示例#4
0
		public PathProcessor (AstarPath astar, PathReturnQueue returnQueue, int processors, bool multithreaded) {
			this.astar = astar;
			this.returnQueue = returnQueue;

			if (processors < 0) {
				throw new System.ArgumentOutOfRangeException("processors");
			}

			if (!multithreaded && processors != 1) {
				throw new System.Exception("Only a single non-multithreaded processor is allowed");
			}

			// Set up path queue with the specified number of receivers
			queue = new ThreadControlQueue(processors);
			threadInfos = new PathThreadInfo[processors];

			for (int i = 0; i < processors; i++) {
				threadInfos[i] = new PathThreadInfo(i, astar, new PathHandler(i, processors));
			}

			if (multithreaded) {
				threads = new Thread[processors];

				// Start lots of threads
				for (int i = 0; i < processors; i++) {
					var threadIndex = i;
					var thread = new Thread (() => CalculatePathsThreaded(threadInfos[threadIndex]));
					thread.Name = "Pathfinding Thread " + i;
					thread.IsBackground = true;
					threads[i] = thread;
					thread.Start();
				}
			} else {
				// Start coroutine if not using multithreading
				threadCoroutine = CalculatePaths(threadInfos[0]);
			}
		}
 // Token: 0x0600236D RID: 9069 RVA: 0x001991F8 File Offset: 0x001973F8
 internal PathProcessor(AstarPath astar, PathReturnQueue returnQueue, int processors, bool multithreaded)
 {
     this.astar       = astar;
     this.returnQueue = returnQueue;
     if (processors < 0)
     {
         throw new ArgumentOutOfRangeException("processors");
     }
     if (!multithreaded && processors != 1)
     {
         throw new Exception("Only a single non-multithreaded processor is allowed");
     }
     this.queue        = new ThreadControlQueue(processors);
     this.pathHandlers = new PathHandler[processors];
     for (int i = 0; i < processors; i++)
     {
         this.pathHandlers[i] = new PathHandler(i, processors);
     }
     if (multithreaded)
     {
         this.threads = new Thread[processors];
         for (int j = 0; j < processors; j++)
         {
             PathHandler pathHandler = this.pathHandlers[j];
             this.threads[j] = new Thread(delegate()
             {
                 this.CalculatePathsThreaded(pathHandler);
             });
             this.threads[j].Name         = "Pathfinding Thread " + j;
             this.threads[j].IsBackground = true;
             this.threads[j].Start();
         }
         return;
     }
     this.threadCoroutine = this.CalculatePaths(this.pathHandlers[0]);
 }