function out = ticBytes(aPool)
%

% Copyright 2016-2020 The MathWorks, Inc.

if numel(aPool) > 1
    % If a pool is provided, it must be a scalar pool.
    error(message("MATLAB:parallel:pool:ScalarPoolRequired", "ticBytes"));
end
if ~isempty(aPool)
    errorIfPoolNotUsable(aPool);
end

currentState = parallel.pool.TicBytesResult(aPool);

if nargout > 0
    % Output requested so return and DO NOT set the internally held
    % state
    out = currentState;
else
    if ~isempty(aPool)
        aPool.PreviousTicBytesResult = currentState;
    else
        parallel.Pool.hEmptyPoolPreviousTicBytesResult(currentState);
    end
end

