function this = updateTimingPlotsAndOutput(this, FinishedIterationNums)
% If running in parallel, there may be no new finished
% iterations, but we still want to plot because there may be
% new pending points.
%

%   Copyright 2016-2022 The MathWorks, Inc.

if ~isempty(FinishedIterationNums)
    this.PrivIterationTimeTrace(FinishedIterationNums) = toc(this.IterationStartTime);
    this.IterationStartTime = tic;
    % using loop since the vectorized version of the
    % below lines cannot return the object. Returning the
    % object is important for the resume functionality as the
    % changes to the resumeFlag needs to be tracked across
    % iterations
    for i=1:numel(FinishedIterationNums)
        printProgress(this, FinishedIterationNums(i), numel(FinishedIterationNums),this.PrivOptions.isResuming);
        this.PrivOptions.isResuming = false;
    end
    % Update total elapsed times
    this.TotalElapsedTimeTrace = [this.TotalElapsedTimeTrace;
        repmat(this.PreviousTime + toc(this.CurrentRunStartTime), numel(FinishedIterationNums), 1)];
    this = callOutputFcn(this, 'iteration');
end
%  Update plots
this = callPlotFcn(this, 'iteration');
end
