/// <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(); } }
/// <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(); }
/// <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(); } }
/// <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(); }