상속: ThreadBase
 /// <summary>
 /// Creates a new instance of the TaskDistributor.
 /// </summary>
 /// <param name="workerThreadCount">The number of worker threads, a value below one will create ProcessorCount x2 worker threads.</param>
 /// <param name="autoStart">Should the instance auto start the worker threads.</param>
 public TaskDistributor(string name, int workerThreadCount, bool autoStart)
     : base()
 {
     this.name = name;
     if (workerThreadCount <= 0)
     {
         workerThreadCount = ThreadBase.AvailableProcessors * 2;
     }
     workerThreads = new TaskWorker[workerThreadCount];
     lock (workerThreads)
     {
         for (var i = 0; i < workerThreadCount; ++i)
         {
             workerThreads[i] = new TaskWorker(name, this);
         }
     }
     if (mainTaskDistributor == null)
     {
         mainTaskDistributor = this;
     }
     if (autoStart)
     {
         Start();
     }
 }
예제 #2
0
		/// <summary>
		/// Creates a new instance of the TaskDistributor.
		/// </summary>
        /// <param name="workerThreadCount">The number of worker threads, a value below one will create ProcessorCount x3 worker threads.</param>
		/// <param name="autoStart">Should the instance auto start the worker threads.</param>
		public TaskDistributor(int workerThreadCount, bool autoStart)
			: base()
		{
            if (workerThreadCount <= 0)
            {
#if !NO_UNITY
                workerThreadCount = UnityEngine.SystemInfo.processorCount * 2;
#else
                workerThreadCount = Environment.ProcessorCount * 2;
#endif
            }

			workerThreads = new TaskWorker[workerThreadCount];
			lock (workerThreads)
			{
				for (var i = 0; i < workerThreadCount; ++i)
					workerThreads[i] = new TaskWorker(this);
			}

			if (mainTaskDistributor == null)
				mainTaskDistributor = this;

			if (autoStart)
				Start();
		}
예제 #3
0
        /// <summary>
        /// Creates a new instance of the TaskDistributor.
        /// </summary>
        /// <param name="workerThreadCount">The number of worker threads, a value below one will create ProcessorCount x3 worker threads.</param>
        /// <param name="autoStart">Should the instance auto start the worker threads.</param>
        public TaskDistributor(int workerThreadCount, bool autoStart)
            : base()
        {
            if (workerThreadCount <= 0)
            {
#if !NO_UNITY
                workerThreadCount = UnityEngine.SystemInfo.processorCount * 3;
#else
                workerThreadCount = Environment.ProcessorCount * 3;
#endif
            }

            workerThreads = new TaskWorker[workerThreadCount];
            lock (workerThreads)
            {
                for (var i = 0; i < workerThreadCount; ++i)
                {
                    workerThreads[i] = new TaskWorker(this);
                }
            }

            if (mainTaskDistributor == null)
            {
                mainTaskDistributor = this;
            }

            if (autoStart)
            {
                Start();
            }
        }
예제 #4
0
        /// <summary>
        /// Creates a new instance of the TaskDistributor.
        /// </summary>
        /// <param name="workerThreadCount">The number of worker threads, a value below one will create ProcessorCount x2 worker threads.</param>
        /// <param name="autoStart">Should the instance auto start the worker threads.</param>
        public TaskDistributor(string name, int workerThreadCount, bool autoStart)
            : base()
        {
            this.name = name;
            if (workerThreadCount <= 0)
                workerThreadCount = ThreadBase.AvailableProcessors * 2;

            workerThreads = new TaskWorker[workerThreadCount];
            lock (workerThreads)
            {
                for (var i = 0; i < workerThreadCount; ++i)
                    workerThreads[i] = new TaskWorker(name, this);
            }

            if (mainTaskDistributor == null)
                mainTaskDistributor = this;

            if (autoStart)
                Start();
        }