Ejemplo n.º 1
0
        private void Awake()
        {
            DontDestroyOnLoad(this);
            _instance = this;
            run       = true;
            switch (cpuLoad)
            {
            case CPULoad.Single:
                threadCount = 1;
                break;

            case CPULoad.Low:
                threadCount = Math.Max(1, Environment.ProcessorCount / 2);
                break;

            case CPULoad.Medium:
                threadCount = Math.Max(1, Environment.ProcessorCount - 1);
                break;

            case CPULoad.High:
                threadCount = Environment.ProcessorCount;
                break;
            }
            StartThread();
        }
Ejemplo n.º 2
0
 public override void Update()
 {
     if (!WorkController.run)
     {
         run = false;
         return;
     }
     while (WorkController.HasWork && WorkController.run)
     {
         currentWork = WorkController.GetWork();
         currentWork?.Invoke();
     }
 }