public void RunSubtasks()
        {
            if (isRunning)
            {
                throw new Exception($"[{nameof(SubtaskExecutor)}] Allready running!");
            }
            if (runner == null)
            {
                throw new Exception($"[{nameof(SubtaskExecutor)}] No '{nameof(Runner.SubtaskRunner)}' provided!");
            }
            isRunning = true;

            profilerTrack?.LogStartWork();

            if (totalSubtaskCount == 0)
            {
                remainingBatches = 0;
                Complete();
            }
            else
            {
                remainingBatches = (totalSubtaskCount - 1) / batchSize + 1;                 //'Trick' to round up using integer division

                int startOffset = batchSize - 1;
                int maxIndex    = totalSubtaskCount - 1;
                for (int i = 0; i < totalSubtaskCount; i += batchSize)
                {
                    int start = i;
                    int end   = start + startOffset;
                    runner.PushTask(this, start, end >= totalSubtaskCount ? maxIndex : end);
                }
                runner.WakeExecutors();
            }
        }
Exemplo n.º 2
0
        public void QueryTasks()
        {
            if (isRunning)
            {
                throw new Exception($"[{nameof(TaskQuerier)}] Allready running!");
            }
            isRunning = true;

            profilerTrack?.LogStartWork();

            remainingQueries = tasks.Length;
            if (remainingQueries == 0)
            {
                Complete();
            }
            else
            {
                for (int i = 0; i < tasks.Length; i++)
                {
                    runner.PushTask(this, i, i);
                }
                runner.WakeExecutors();
            }
        }